Avatar of light_tuner
light_tuner
 asked on

change the width value of an embedded video using preg_replace or similar

Dear all,
I have been looking at a simple solution to change the width (and height, but I imagine once I know for the width it is easy to change the height in the same manner) of embedded videos.

I can't imagine it is difficult, but I just can't get my head around regular expressions.

Thank you in advance
example of embedded video code:
 
<object width="446" height="326"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param> <param name="flashvars" value="vu=http://video.ted.com/talks/embed/JohnMaeda_2007-embed_high.flv&su=http://images.ted.com/images/ted/tedindex/embed-posters/JohnMaeda-2007.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=172" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="446" height="326" allowFullScreen="true" flashvars="vu=http://video.ted.com/talks/embed/JohnMaeda_2007-embed_high.flv&su=http://images.ted.com/images/ted/tedindex/embed-posters/JohnMaeda-2007.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=172"></embed></object>

Open in new window

PHP

Avatar of undefined
Last Comment
Ionut A. Tudor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ionut A. Tudor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
light_tuner

ASKER
Hi al3cs12,

thanks a lot for your post. it does what it supposed to do (i.e. changing width end height) but using the example I provided, it crops the video.

Is there a way to scale the video to match the size I am setting?

Thanks
light_tuner

ASKER
just to make sure (and my apology if I didn't formulate my question properly)
how would I go about scaling the width and height according to the desired width?

I imagine I would need to know both values to get the ratio and then deduce the new height from the width I set?

Thanks again
Ionut A. Tudor

I think changing &vw=432&vh=240 parameters should do the trick
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Ionut A. Tudor

those parameters are set in the url, because the object and embed width and height automatically resizes the movie, but that parameters in the url &vw=432&vh=240 also sets the width and height, you need to replace these also. Good luck