Insert wmode parameter into oEmbeds

Adding this snippet to the functions.php of your wordpress theme will add the wmode parameter to oembeds. What is oEmbed? For example oEmbed will turn a youtube URL into an embedded video without the need to add any html. Supported websites: YouTube, Vimeo, DailyMotion, blip.tv, Flickr, Viddler, Hulu, Qik, Revision3, Scribd, Photobucket, PollDaddy, Google Video, WordPress.tv, SmugMug, FunnyOrDie.com

 

 

add_filter( 'oembed_result', 'slt_wmode_opaque', 10, 3 );
function slt_wmode_opaque( $html, $url, $args ) {
if ( strpos( $html, '<param name="movie"' ) !== false )
$html = preg_replace( '|</param>|', '</param><param name="wmode" value="opaque"></param>', $html, 1 );
if ( strpos( $html, '<embed' ) !== false )
$html = str_replace( '<embed', '<embed wmode="opaque"', $html );
return $html;
}

Leave a comment