add_filter to embed_oembed_html to get wmode transparent

By Chris "MUG5" Maguire on August 20, 2010 in Tech / Coding Related
w0
k 0

The video embedded by WordPress 2.9 doesn’t have the parameters <param name=’wmode’ value=’transparent’ /> and <embed wmode=”transparent” … >.

This makes it stay above a dropdown menu and any other elements on the
page. Yes, it is possible to modify the code returned by oEmbed for flash videos!
You have to use the add_filter function of WordPress to modify the embed_oembed_html.

The code below filters the embed code stored by WordPress in the database. Tis code just inserts <param name=”wmode” value=”transparent”></param> and wmode=”transparent” in the required places.

Create a file functions.php or use the one in your themes folder if there is. Put the code given below before the closing ‘?>’ at the end of this file. As soon this code is in place, it should filter the video object and embed code. The problem of a dissappearing menu should be gone!

The code snippet for your theme’s functions.php:

function add_transparent($oembvideo) { $patterns = array(); $replacements = array(); $patterns[] = '/<\/param><embed/'; $patterns[] = '/allowscriptaccess="always"/'; $replacements[] = '</param><param name="wmode" value="transparent"></param><embed'; $replacements[] = 'wmode="transparent" allowscriptaccess="always"'; return preg_replace($patterns, $replacements, $oembvideo); return $oembvideo; } add_filter('embed_oembed_html', 'add_transparent');

please BACKUP original files to be able to step back!!

This tip was found here:

http://forum.go41.de/topic/add_filter-to-embed_oembed_html-to-get-wmode-transparent

About the Author

Chris "MUG5" MaguireView all posts by Chris "MUG5" Maguire >
I am a freelance Creative Director / Multimedia Futurist capable of producing hi-end work, to tight time-frames, both nationally and internationally, whatever the required medium (music, design, film, photography, art and writing). A hands on executive, I am as capable leading a team to success as I am being the team – taking projects from concept to completion single handedly if the need presents itself. Need a team for your project but only have the budget for one or two people? I’m the guy that can help you get a team’s worth of work on your budget.