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;
|
$width = $w;
|
||||||
|
|
||||||
|
$yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
|
||||||
|
|
||||||
$primary = false;
|
$primary = false;
|
||||||
if ( ! empty( $src ) ) {
|
if ( ! empty( $src ) ) {
|
||||||
$type = wp_check_filetype( $src, wp_get_mime_types() );
|
if ( ! preg_match( $yt_pattern, $src ) ) {
|
||||||
if ( ! in_array( strtolower( $type['ext'] ), $default_types ) )
|
$type = wp_check_filetype( $src, wp_get_mime_types() );
|
||||||
return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) );
|
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;
|
$primary = true;
|
||||||
array_unshift( $default_types, 'src' );
|
array_unshift( $default_types, 'src' );
|
||||||
} else {
|
} else {
|
||||||
|
@ -1216,10 +1221,15 @@ function wp_video_shortcode( $attr, $content = '' ) {
|
||||||
if ( ! empty( $$fallback ) ) {
|
if ( ! empty( $$fallback ) ) {
|
||||||
if ( empty( $fileurl ) )
|
if ( empty( $fileurl ) )
|
||||||
$fileurl = $$fallback;
|
$fileurl = $$fallback;
|
||||||
$type = wp_check_filetype( $$fallback, wp_get_mime_types() );
|
|
||||||
// m4v sometimes shows up as video/mpeg which collides with mp4
|
if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) {
|
||||||
if ( 'm4v' === $type['ext'] )
|
$type = array( 'type' => 'video/youtube' );
|
||||||
$type['type'] = 'video/m4v';
|
} 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 ) );
|
$html .= sprintf( $source, $type['type'], esc_url( $$fallback ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue