Let the video shortcode accept a YouTube URL as the value of its `src` attribute, as MediaElement.js supports Chromeless YouTube videos by using a pseudo-mime-type `video/youtube`.
HTTP and HTTPS www, non-www, and short url fronts are supported: http://www.youtube.com/watch https://www.youtube.com/watch http://youtube.com/watch https://youtube.com/watch http://youtu.be https://youtu.be Fixes #24764. Built from https://develop.svn.wordpress.org/trunk@27063 git-svn-id: http://core.svn.wordpress.org/trunk@26936 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7b4b508b91
commit
84911b9707
|
@ -1147,11 +1147,16 @@ function wp_video_shortcode( $attr, $content = '' ) {
|
|||
|
||||
$width = $w;
|
||||
|
||||
$yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
|
||||
|
||||
$primary = false;
|
||||
if ( ! empty( $src ) ) {
|
||||
if ( ! preg_match( $yt_pattern, $src ) ) {
|
||||
$type = wp_check_filetype( $src, wp_get_mime_types() );
|
||||
if ( ! in_array( strtolower( $type['ext'] ), $default_types ) )
|
||||
if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
|
||||
return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) );
|
||||
}
|
||||
}
|
||||
$primary = true;
|
||||
array_unshift( $default_types, 'src' );
|
||||
} else {
|
||||
|
@ -1216,10 +1221,15 @@ function wp_video_shortcode( $attr, $content = '' ) {
|
|||
if ( ! empty( $$fallback ) ) {
|
||||
if ( empty( $fileurl ) )
|
||||
$fileurl = $$fallback;
|
||||
|
||||
if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) {
|
||||
$type = array( 'type' => 'video/youtube' );
|
||||
} else {
|
||||
$type = wp_check_filetype( $$fallback, wp_get_mime_types() );
|
||||
// m4v sometimes shows up as video/mpeg which collides with mp4
|
||||
if ( 'm4v' === $type['ext'] )
|
||||
$type['type'] = 'video/m4v';
|
||||
}
|
||||
$html .= sprintf( $source, $type['type'], esc_url( $$fallback ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue