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:
- YouTube (only public videos and playlists - "unlisted" and "private" videos will not embed)
- Vimeo
- DailyMotion
- blip.tv
- Flickr (both videos and images)
- Viddler
- Hulu
- Qik
- Revision3
- Scribd
- Photobucket
- PollDaddy
- WordPress.tv (only VideoPress-type videos for the time being)
- SmugMug (WordPress 3.0+)
- FunnyOrDie.com (WordPress 3.0+)
- Twitter (WordPress 3.4+)
For any of these videos, you can support multiple widths so that the video is "full" content width. For example, check out these examples:
- Video on my site on full-width
- Video on my site on sidebar-content-sidebar
- Video on my site on sidebar-content
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.