Make WordPress Core


Ignore:
Timestamp:
10/13/2009 10:36:24 PM (17 years ago)
Author:
ryan
Message:

Use oEmbed for youtube. Props Viper007Bond. see #10337

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-embeds.php

    r12023 r12027  
    77 * @subpackage Embeds
    88 */
    9 
    10 /**
    11  * The YouTube.com embed handler callback. YouTube does not support oEmbed and we want to provide extra customization.
    12  *
    13  * @see WP_Embed::register_handler()
    14  * @see WP_Embed::shortcode()
    15  *
    16  * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
    17  * @param array $attr Embed attributes.
    18  * @param string $url The original URL that was matched by the regex.
    19  * @param array $rawattr The original unmodified attributes.
    20  * @return string The embed HTML.
    21  */
    22 function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
    23         // If the user supplied a fixed width AND height, use it
    24         if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
    25                 $width  = (int) $rawattr['width'];
    26                 $height = (int) $rawattr['height'];
    27         } else {
    28                 list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
    29         }
    30 
    31         return apply_filters( 'embed_youtube', '<object width="' . esc_attr($width) . '" height="' . esc_attr($height) . '"><param name="movie" value="http://www.youtube.com/v/' . esc_attr($matches[3]) . '&amp;hl=en&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . esc_attr($matches[3]) . '&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '"></embed></object>', $matches, $attr, $url, $rawattr );
    32 }
    33 wp_embed_register_handler( 'youtube', '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/(watch\?v=|w/\?v=|\?v=)([\w-]+)(.*?)#i', 'wp_embed_handler_youtube' );
    34 
    359
    3610/**
Note: See TracChangeset for help on using the changeset viewer.