Resize embed code PHP
Can I automatically resize an embed code efficiently using PHP (maybe with regex?开发者_JAVA技巧)
Here's an example of the embed code:
<object width="500" height="350">
<param name="movie" value="http://www.megavideo.com/v/"></param>
<param name="allowFullScreen" value="true"></param>
<embed src="http://www.megavideo.com/v/"
type="application/x-shockwave-flash"
allowfullscreen="true"
width="500" height="350">
</embed>
</object>
I think your question is asking how to change the width and height of the <object>
tag? If so, if you want to use PHP, you'll have to refresh the page, which you probably don't want to do in this case, since your user will have to reload the video (obviously you would simply output new values to the width
and height
values).
Instead, you're probably going to want to use JavaScript. Give your object a name, and use JavaScript (with jQuery, etc. if you must) to change the dimensions. This will allow you to change the dimensions without reloading the page.
Do something like
preg_replace('(<[^>]*?)width="[^"]*" height="[^"]*"', '$1width="100" height="200");
(code untested)
精彩评论