Use the WordPress embed function to quickly insert Youku videos

Source: Internet
Author: User
Tags blog layout wordpress blog

The easy embeds feature added in WordPress 2.9 allows you to directly publish a URL (a single line, plain text, without a link ).
The video in the URL is displayed on the Wordpress blog, and the video size is adjusted based on the blog layout.

However, by default, the youku video sharing website in China is not supported. I created the following plug-in based on the WordPress embeds interface, allowing your Wordpress blog to publish Youku videos through a line of links, you do not need to find the complex and troublesome Flash Embedded Code of Youku.

function wp_embed_handler_youku( $matches, $attr, $url, $rawattr ) {    // If the user supplied a fixed width AND height, use it    if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {        $width  = (int) $rawattr['width'];        $height = (int) $rawattr['height'];    } else {        list( $width, $height ) = wp_expand_dimensions( 480, 400, $attr['width'], $attr['height'] );    }     return apply_filters( 'embed_youku', '<embed src="http://player.youku.com/player.php/sid/' . esc_attr($matches[1]) . '/v.swf" quality="high" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>', $matches, $attr, $url, $rawattr ); }wp_embed_register_handler( 'youku', '#http://v.youku.com/v_show/id_(.*?).html#i', 'wp_embed_handler_youku' );

Put the above Code in the current topic'sfunctions.phpFile, or add a plug-in header, upload it to the plug-in directory, and activate it.

After the installation, you only need to paste the youku video link directly into the WordPress log Content to display the video. If xxxxxxx is the video ID, the insertion method is:

Or

[Embed] http://v.youku.com/v_show/id_xxxxxxxxxxxxx.html#/embed]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.