ErikSoderstrom.com

Share this post

How to Keep Your Wordpress Automatic oEmbeds from Being too Wide

www.eriksoderstrom.com

How to Keep Your Wordpress Automatic oEmbeds from Being too Wide

Erik
Apr 13, 2013
Share this post

How to Keep Your Wordpress Automatic oEmbeds from Being too Wide

www.eriksoderstrom.com

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.

Share this post

How to Keep Your Wordpress Automatic oEmbeds from Being too Wide

www.eriksoderstrom.com
Comments
TopNew

No posts

Ready for more?

© 2023 Erik Soderstrom, LLC
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing