Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: YouTube wmode adjuster
- Description: This plugin will modify the YouTube oEmbed output and add some parameters.
- Author: Jan Dembowski
- Author URI: http://blog.dembowski.net/
- Version: 0.2
- */
- /*
- From http://wordpress.org/support/topic/help-adding-wmodetransparent-to-oembeds
- Example:
- <iframe width="625" height="352" src="http://www.youtube.com/embed/MCWJUSulnro?feature=oembed" frameborder="0" allowfullscreen></iframe>
- Replace ?feature=oembed with ?wmode=transparent and add wmode="Opaque" to the end of the <iframe ...>
- <iframe width="625" height="352" src="http://www.youtube.com/embed/MCWJUSulnro?wmode=transparent" frameborder="0" allowfullscreen wmode="Opaque"></iframe>
- */
- add_filter('embed_oembed_html','mh_adjustyoutube',10,3);
- function mh_adjustyoutube( $html, $url, $args ) {
- if ( strstr($url, 'youtube.com') ) {
- // Replace ?feature=oembed
- $mh_new = str_replace( "?feature=oembed" , "?wmode=transparent" , $html );
- // Append wmode="Opaque"
- $mh_new = preg_replace( '/\><\/iframe>$/' , ' wmode="Opaque"></iframe>' , $mh_new );
- $html = $mh_new;
- }
- // Modified or not return $html
- return $html;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement