Resize YouTube Embed 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="http://www.youtube.com/ v/SOiGqFceMYo&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/SOiGqFceMYo&hl=en&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;

?>

Now try to resize youtube player with php regular expression replace preg_replace()……

5 comments so far

  1. Hi, good post. I have been thinking about this issue,so thanks for sharing. I will certainly be coming back to your blog.

  2. Hi, nice post. I have been pondering this topic,so thanks for writing. I will definitely be coming back to your posts.

  3. Richy on

    Thaks you ;)

  4. scott sherman on

    Hi Sandeep,

    I came across your blog related to a search I was doing on the AWS site. I have a new web effort that I am beginning to plan. I would like to get more insight into the kind of projects you have worked on, what is your specialties, and, get an idea as to how much you charge.

    I look forward to hearing from you.

    I tried to send you an email via gmail. I am posting here too.

    Thanks,
    Scott

  5. alejandro nogales on

    hello Sandeep. i found you, not by Googling you, but because I was looking to resize Flash Videos via CSS (i think JS is more likely the solution).

    and voila, i landed on a page of a dude i know. cool.


Leave a reply