Changeset 24000
- Timestamp:
- 04/16/2013 11:06:31 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/media.php
r23992 r24000 1326 1326 return; 1327 1327 wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); 1328 wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); 1329 wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 ); 1328 1330 } 1329 1331 … … 1350 1352 1351 1353 return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr ); 1354 } 1355 1356 /** 1357 * Audio embed handler callback. 1358 * 1359 * @since 3.6.0 1360 * 1361 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 1362 * @param array $attr Embed attributes. 1363 * @param string $url The original URL that was matched by the regex. 1364 * @param array $rawattr The original unmodified attributes. 1365 * @return string The embed HTML. 1366 */ 1367 function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { 1368 $audio = $url; 1369 if ( shortcode_exists( 'audio' ) ) 1370 $audio = do_shortcode( '[audio src="' . $url . '" /]' ); 1371 return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); 1372 } 1373 1374 /** 1375 * Video embed handler callback. 1376 * 1377 * @since 3.6.0 1378 * 1379 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 1380 * @param array $attr Embed attributes. 1381 * @param string $url The original URL that was matched by the regex. 1382 * @param array $rawattr The original unmodified attributes. 1383 * @return string The embed HTML. 1384 */ 1385 function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { 1386 $dimensions = ''; 1387 $video = $url; 1388 if ( shortcode_exists( 'video' ) ) { 1389 if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { 1390 $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); 1391 $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); 1392 } elseif ( strstr( $url, home_url() ) ) { 1393 $id = attachment_url_to_postid( $url ); 1394 if ( ! empty( $id ) ) { 1395 $meta = wp_get_attachment_metadata( $id ); 1396 if ( ! empty( $meta['width'] ) ) 1397 $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] ); 1398 if ( ! empty( $meta['height'] ) ) 1399 $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] ); 1400 } 1401 } 1402 $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' ); 1403 } 1404 return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); 1352 1405 } 1353 1406 … … 1996 2049 1997 2050 /** 1998 * Audio embed handler callback.1999 *2000 * @since 3.6.02001 *2002 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.2003 * @param array $attr Embed attributes.2004 * @param string $url The original URL that was matched by the regex.2005 * @param array $rawattr The original unmodified attributes.2006 * @return string The embed HTML.2007 */2008 function wp_audio_embed( $matches, $attr, $url, $rawattr ) {2009 $audio = $url;2010 if ( shortcode_exists( 'audio' ) )2011 $audio = do_shortcode( '[audio src="' . $url . '" /]' );2012 return apply_filters( 'wp_audio_embed', $audio, $attr, $url, $rawattr );2013 }2014 wp_embed_register_handler( 'wp_audio_embed', '#https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')#i', apply_filters( 'wp_audio_embed_handler', 'wp_audio_embed' ), 9999 );2015 2016 /**2017 * Video embed handler callback.2018 *2019 * @since 3.6.02020 *2021 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.2022 * @param array $attr Embed attributes.2023 * @param string $url The original URL that was matched by the regex.2024 * @param array $rawattr The original unmodified attributes.2025 * @return string The embed HTML.2026 */2027 function wp_video_embed( $matches, $attr, $url, $rawattr ) {2028 $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 }2043 }2044 $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' );2045 }2046 return apply_filters( 'wp_video_embed', $video, $attr, $url, $rawattr );2047 }2048 wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')#i', apply_filters( 'wp_video_embed_handler', 'wp_video_embed' ), 9999 );2049 2050 /**2051 2051 * Return suitable HTML code for output based on the content related to the global $post 2052 2052 * If found, remove the content from the @global $post's post_content field
Note: See TracChangeset
for help on using the changeset viewer.