Make WordPress Core

Ticket #24070: 24070.2.diff

File 24070.2.diff, 2.5 KB (added by kovshenin, 12 years ago)
  • wp-includes/media.php

     
    20062006 * @return string The embed HTML.
    20072007 */
    20082008function wp_audio_embed( $matches, $attr, $url, $rawattr ) {
    2009         $audio = $url;
    2010         if ( shortcode_exists( 'audio' ) )
    2011                 $audio = do_shortcode( '[audio src="' . $url . '" /]' );
     2009        $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) );
    20122010        return apply_filters( 'wp_audio_embed', $audio, $attr, $url, $rawattr );
    20132011}
    20142012wp_embed_register_handler( 'wp_audio_embed', '#https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')#i', apply_filters( 'wp_audio_embed_handler', 'wp_audio_embed' ), 9999 );
     
    20262024 */
    20272025function wp_video_embed( $matches, $attr, $url, $rawattr ) {
    20282026        $dimensions = '';
    2029         $video = $url;
    2030         if ( shortcode_exists( 'video' ) ) {
    2031                 if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) {
    2032                         $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] );
    2033                         $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
    2034                 } elseif ( strstr( $url, home_url() ) ) {
    2035                         $id = attachment_url_to_postid( $url );
    2036                         if ( ! empty( $id ) ) {
    2037                                 $meta = wp_get_attachment_metadata( $id );
    2038                                 if ( ! empty( $meta['width'] ) )
    2039                                         $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] );
    2040                                 if ( ! empty( $meta['height'] ) )
    2041                                         $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] );
    2042                         }
     2027
     2028        if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) {
     2029                $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] );
     2030                $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
     2031        } elseif ( strstr( $url, home_url() ) ) {
     2032                $id = attachment_url_to_postid( $url );
     2033                if ( ! empty( $id ) ) {
     2034                        $meta = wp_get_attachment_metadata( $id );
     2035                        if ( ! empty( $meta['width'] ) )
     2036                                $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] );
     2037                        if ( ! empty( $meta['height'] ) )
     2038                                $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] );
    20432039                }
    2044                 $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' );
    20452040        }
     2041
     2042        $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) );
    20462043        return apply_filters( 'wp_video_embed', $video, $attr, $url, $rawattr );
    20472044}
    20482045wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')#i', apply_filters( 'wp_video_embed_handler', 'wp_video_embed' ), 9999 );