Re: How to take video embed codes and change all their widths/heights?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Rob Gould" <GouldIMG@xxxxxxx> wrote in message news:53D0E73E-66A3-4641-9F0F-01A830B13DFC@xxxxxxxxxx
Can anytime give me some insights on how to write a PHP script that could accept any of the below strings below and edit the strings to change their width and height settings dynamically?

For instance, if I want all embedded videos to have a width of 320, and a height of 240, using PHP's string manipulation commands, what's the best way to "hone in" on width="425" and change it to width="320"? (In all cases in each string)



stringtoedit='<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/B1O2jcfOylU&rel=1";></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/B1O2jcfOylU&rel=1 " type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';

stringtoedit='<object width="464" height="388" classid="clsid:d27cdb6e- ae6d-11cf-96b8-444553540000"><param name="movie" value="http://www2.funnyordie.com/public/flash/fodplayer.swf " /><param name="flashvars" value="key=5468" /><param name="allowfullscreen" value="true" /><embed width="464" height="388" flashvars="key=5468" allowfullscreen="true" quality="high" src="http://www2.funnyordie.com/public/flash/fodplayer.swf " type="application/x-shockwave-flash"></embed></object><noscript><a href="http://www.funnyordie.com/videos/5468";>Cars</a> on <a href="http://www.funnyordie.com ">FunnyOrDie.com</a></noscript>';

If you only have those two types that you need to imbed then it might be easier to make a function EmbedYoutubeCode( 'B1O2jcfOylU' ) since the only thing that changes is the ID number near the end of the url, your function could just spit out

function EmbedYoutubeCode( MovieID: String): String;
{
'object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/' + MovieID + '&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' + MovieID + '&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
}

Basiclly you just give it the ID, and it would spit back out the embed code, it also makes for safer code since you coudl also check to make sure that there was no urls or other junk so it's harder to get hacked.

Oh, and sorry about half of that function being written in Pascal, I've been working with it all morning.

- Dan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux