How to Set oEmbed Max Width in WordPress 3.5 with $content_width

85

Today, we saw the release of WordPress 3.5 which came with tons of amazing features. As we upgraded one site after another, we noticed an issue on one of the sites we manage. The embedded video size were changed, and the embedded videos were a lot smaller. We went in the settings to find that the option to specify oEmbed max width and height were removed. In an attempt to simplify the admin panel, the core team got rid of the oEmbed max width and height settings screen. In this article, we will show you how to set oEmbed max width in WordPress 3.5 with $content_width.

What changed? and Why?

In the past, in your Settings » Media screen there was an option to set the oEmbed max width and height.

Media Settings oEmbed Width

Well, this option is no longer there in WordPress 3.5. The decision was made to make things simpler. There is no harm in auto-enabling oEmbeds in WordPress. If it is not enabled by default, beginners often get confused. The core devs also decided to get rid of the oEmbed max width and height fields in favor of using theme’s content width and make the height 1.5 times the content width. If your theme doesn’t have the content width defined, then your oEmbed sizes will be a lot smaller. This is exactly what happened to one of the sites we manage. The theme that was being used did not have $content_width specified.

How to Fix the oEmbed Width Issue in WordPress 3.5

Open your theme’s functions.php file, and add the following code:

  if ( ! isset( $content_width ) ) $content_width = 600;  

Remember to change the number 600 appropriately for your theme. It is the maximum width in pixels for your content area.

Once you do this, WordPress will automatically use that for the maximum width of your oEmbed elements (youtube videos, slideshare, etc).

Social Media Auto Publish Powered By : XYZScripts.com