Want amazing, share-able, conservative quotes? Check out QuotableRight on Twitter, Facebook, or the web.

How to Keep Your WordPress Automatic oEmbeds from Being too Wide

oEmbed is a protocol for retrieving embed code based on a URL. It’s great for bloggers. Instead of manually having to grab the embed code for a video on YouTube, a tweet, or other embed-able content, you can just grab the URL and drop it into your post.

WordPress supports oEmbed from a number of providers including Twitter, Youtube, Intstagram, and Flickr, among others—a full list is available here.

One problem I noticed when using this feature is that YouTube videos would often be embedded at a width that exceeded the width of my content column. When that happened, they would lop over into the sidebar, hardly a professional look.

Fortunately, this is easy to correct by adding the following code to your theme’s functions.php file. Thesis users can add this to their custom.php file (version 2) or custom_functions.php (version 1).

global $content_width;
$content_width = 602;

You will need to change the number 602 to the width of your website’s content column in pixels.

Comments on this entry are closed.