WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 05 2012

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:

  • 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.

Written by Travis Smith · Categorized: Genesis

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Affan Ruslan says

    July 25, 2012 at 11:28 pm

    This is great, but how about the bug?
    Do you know whether it has been fixed?

    Reply
  2. JUICEDaniel says

    January 14, 2014 at 4:27 am

    Is this still valid and the latest tutorial (for Genesis 2.0)? (I want all videos to be embedded with 750px width)

    Reply
    • Travis Smith says

      February 11, 2014 at 10:12 am

      Yes. This code is not Genesis specific. However, proper use of the global $content_width may be a better approach within Genesis.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in