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]

 



$stringtoedit = preg_replace("/width=(\"?[0-9%]\"?[^0-9%\"])/msi",
"width=\"\\1\"", $stringtoedit);
$stringtoedit = preg_replace("/height=(\"?[0-9%]\"?[^0-9%\"])/msi",
"height=\"\\1\"", $stringtoedit);

This "adds" quotes around quote-less values, which were once
acceptable HTML, but aren't really a Good Idea.

It also allows for a % in the value, which is still used in some
places, and may even still be valid.

You MIGHT want to actually pull out $width and $height and then change
them proporationally rather than forcing a movie to an aspect ratio
that might suck.

You're on your own to do the arithmetic on that one, but find any
"scale image" PHP script to see how it's done.

On Tue, January 15, 2008 4:25 pm, Rob Gould wrote:
> 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>';
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
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