show html elements on top of youtube video – youtube embed z index – wmode transparent

PHP Add comments

Assume that you are managing youtube videos in your site admin panel. So they are dynamically displayed in web pages.
Youtube video embed code, as i have seen does not include the option of making the video go behind HTML elements.
When we do some animation you can see that the youtube video is on top of all.

So we need to include the wmode transparent option in the embedd code before displaying.
This attribute(param) will make the youtube video go behing any popups.

Here is the simple code to insert the wmode transparent option into the url before displaying it.

<div class='youtubevideo'>
$string = $url;//youtube video url from database
$string = str_replace("<embed","<param name='wmode' value='transparent'></param><embed",$string);
$string = str_replace("<embed","<embed wmode='transparent' ",$string);
echo $string;

How to replace the width and height of an embed code or youtube video

Leave a Reply

Entries RSS