Skip to content

Commit

Permalink
When rendering an audio or video shortcode in IE 6-8, call document.c…
Browse files Browse the repository at this point in the history
…reateElement() as a poor man's HTML5 shiv. see #24902.

git-svn-id: http://core.svn.wordpress.org/trunk@24931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
nacin committed Jul 31, 2013
1 parent ab8dbde commit bd1d854
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,10 @@ function wp_audio_shortcode( $attr ) {
$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
}

$html = sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) );
$html = '';
if ( 'mediaelement' === $library && 1 === $instances )
$html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
$html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) );

$fileurl = '';
$source = '<source type="%s" src="%s" />';
Expand All @@ -940,7 +943,7 @@ function wp_audio_shortcode( $attr ) {
$html .= wp_mediaelement_fallback( $fileurl );
$html .= '</audio>';

return apply_filters( 'wp_audio_shortcode', $html, $atts, $audio, $post_id );
return apply_filters( 'wp_audio_shortcode', $html, $atts, $audio, $post_id, $library );
}
add_shortcode( 'audio', apply_filters( 'wp_audio_shortcode_handler', 'wp_audio_shortcode' ) );

Expand Down Expand Up @@ -1061,7 +1064,10 @@ function wp_video_shortcode( $attr ) {
$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
}

$html = sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );
$html = '';
if ( 'mediaelement' === $library && 1 === $instances )
$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
$html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );

$fileurl = '';
$source = '<source type="%s" src="%s" />';
Expand All @@ -1081,7 +1087,7 @@ function wp_video_shortcode( $attr ) {
$html .= '</video>';

$html = sprintf( '<div style="width: %dpx; max-width: 100%%;">%s</div>', $width, $html );
return apply_filters( 'wp_video_shortcode', $html, $atts, $video, $post_id );
return apply_filters( 'wp_video_shortcode', $html, $atts, $video, $post_id, $library );
}
add_shortcode( 'video', apply_filters( 'wp_video_shortcode_handler', 'wp_video_shortcode' ) );

Expand Down

0 comments on commit bd1d854

Please sign in to comment.