Ticket #24070: 24070.2.diff
File 24070.2.diff, 2.5 KB (added by , 12 years ago) |
---|
-
wp-includes/media.php
2006 2006 * @return string The embed HTML. 2007 2007 */ 2008 2008 function 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 ) ); 2012 2010 return apply_filters( 'wp_audio_embed', $audio, $attr, $url, $rawattr ); 2013 2011 } 2014 2012 wp_embed_register_handler( 'wp_audio_embed', '#https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')#i', apply_filters( 'wp_audio_embed_handler', 'wp_audio_embed' ), 9999 ); … … 2026 2024 */ 2027 2025 function wp_video_embed( $matches, $attr, $url, $rawattr ) { 2028 2026 $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'] ); 2043 2039 } 2044 $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' );2045 2040 } 2041 2042 $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); 2046 2043 return apply_filters( 'wp_video_embed', $video, $attr, $url, $rawattr ); 2047 2044 } 2048 2045 wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')#i', apply_filters( 'wp_video_embed_handler', 'wp_video_embed' ), 9999 );