Sample Code
<?phpThe above code will resize the embed video into the size we are given.
//eg :
$video = "<object width="640" height="385">
<param value="http://www.youtube.com/v/bIx5vDn28eE?fs=1&hl=en_US" name="movie" />
<param value="true" name="allowFullScreen" />
<param value="always" name="allowscriptaccess" /><embed width="640" height="385" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/bIx5vDn28eE?fs=1&hl=en_US"></embed></object>";
// our prefered size : width="208" height="103"
// regular exression to change the height and width
$pattern = "/height=\"[0-9]*\"/";
$video = preg_replace($pattern, "height='103'", $video);
$pattern = "/width=\"[0-9]*\"/";
$video = preg_replace($pattern, "width='208'", $video);
echo $video;
?>
If we want to add the 'wmode' in the video we can assign that value along with the width parameter.
eg :
$video = preg_replace($pattern, "width='208' wmode='transparent'", $video);
No comments:
Post a Comment