How to Dynamically Change the oEmbed Width and Height in WordPress


Web Collections
Inez Ross

$youtube = <<<EOF
<object width=”480″ height=”295″>
<param name=”movie”
value=”http://www.youtube.com/v/Xq-HRHMEmfg&hl=en&fs=1″></param>
<param name=”allowFullScreen” value=”true”></param>
<param name=”allowscriptaccess” value=”always”></param>
<embed src=”http://www.youtube.com/v/Xq-HRHMEmfg&hl=en&fs=1″
type=”application/x-shockwave-flash” allowscriptaccess=”always”
allowfullscreen=”true” width=”480″ height=”295″></embed>
</object>
EOF;

The WP Guru
Marianne Foster

oEmbed is complex stuff, and WordPress uses it when you add say a YouTube URL on its own line to see how wide a video needs to be when the post is displayed. Rather than parsing the actual resource at display time, the oEmbed protocol is a handshake between your blog and the resource provider (in our example, YouTube). The site receives what the resource is and the best content for the width that’s requested.

Be the first to comment

Leave a Reply

Your email address will not be published.


*