/ Published in: PHP
WordPress allows you to embed videos so easily using oEmbed. You can easily add videos to your post just pasting their URL to your post. WordPress handles all the object and embed HTML for you. But this code is missing wmode parameter which is necessary for CSS z-index to work.
Here I will show you how to filter the HTML for the embedded video and add this parameter so easily. For this we will use the oembed_dataparse filter which is run when a user adds a video to the post. Place the following code in your theme's functions.php file:
Here I will show you how to filter the HTML for the embedded video and add this parameter so easily. For this we will use the oembed_dataparse filter which is run when a user adds a video to the post. Place the following code in your theme's functions.php file:
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function stf_embed_filter( $html, $data, $url ){ $html = preg_replace('!(<object[^>]*>)(.*?)</object>!is', "$1$2<param name=\"wmode\" value=\"opaque\"></object>", $html); $html = preg_replace('!(<embed[^>](.*?)>)(.*?)</embed>!is', "<embed $2 wmode=\"opaque\">$3</embed>", $html); return $html; } add_filter('oembed_dataparse', 'stf_embed_filter', 90, 3 );
URL: http://shailan.com/how-to-make-auto-embedded-videos-obey-z-index/