Resize YouTube Video

Here is the code how to resize youtube video embed code, even this code will work to non-youtube embed videos…..

<?php

$embed = ‘<object width=”425″ height=”344″><param name=”movie” value=”https://www.youtube.com/v/jWDmG3JnNLE&hl=en_US&fs=1&”></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”https://www.youtube.com/v/jWDmG3JnNLE&hl=en_US&fs=1&” type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”425″ height=”344″></embed></object>’;

//$alt = preg_match_all(‘/(width|height)=(“[^”]*”)/i’, $embed, $matches);

$embed = preg_replace(‘/(width)=(“[^”]*”)/i’, ‘width=”200″‘, $embed);
$embed = preg_replace(‘/(height)=(“[^”]*”)/i’, ‘height=”200″‘, $embed);

echo $embed;

?>

Output here: