Site icon WP Smith

How to Embed Videos at Different Sizes in Genesis (and other Themes)

Need to embed videos but hate the limitation that you cannot have the same post appear with the same video on different sizes? WordPress provides a little known filter (embed_defaults) that will enable you to easily change the height and width of an embeded object.


Currently, WordPress allows oEmbed by default, and it supports the following sites:

For any of these videos, you can support multiple widths so that the video is "full" content width. For example, check out these examples:

So how did I do this? In HTML mode, I inserted the url

http://www.youtube.com/watch?v=R2a8TRSgzZY

and clicked publish. Then in my functions.php file, I have this code:

*NOTE: In Genesis 1.8, this function will break the blog page template due to a bug that will hopefully be fixed in the next version.

In this function, we are filtering a WordPress function wp_embed_defaults() that creates default array of embed parameters when do_shortcode is used (which is applied to the_content).

For other themes, the code would be modified to use the standard WordPress conditionals.