add_filter to embed_oembed_html to get wmode transparent

von Joern am 24. Dez. 2009 | Keine Kommentare

The video embedded by WordPress 2.9 hasn’t 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!!
you find me on Google+, Twitter and Facebook

(von: master)

Hier noch 3 weitere Ergebnisse dieses Threads:

Re: add_filter to embed_oembed_html to get wmode transparent :: Reply by s0206

21. Aug. 2010 (von: s0206)

Hi thereI tried adding this to my functions file but it made no difference whatsoever. I am using wordpress 3.0.Any idea's on how to get it working?Thanks in advance Weiterlesen →

Re: add_filter to embed_oembed_html to get wmode transparent :: Reply by master

21. Aug. 2010 (von: master)

Using WordPress 3.0.1 I just copied the source code of FireFox. For an embeded video the code looks like this with the function above in functions.php<object width="450" height="363"><param name="movie" value="http://www.youtube.com/v/wLph9-ZkMX8&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/wLph9-ZkMX8&fs=1" type="application/x-shockwave-flash" width="450" height="363"…

Re: add_filter to embed_oembed_html to get wmode transparent :: Reply by s0206

21. Aug. 2010 (von: s0206)

Thank you very much!I was embedding the code form youtube rather than just using a plain url. This works great.Thanks once again! Weiterlesen →


Du findest mich auch auf Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

weitere forum Beiträge: