CSS WP.blogspot.com

Easy methods to Set oEmbed Max Width in WordPress three.5 with $content_width

Immediately, we noticed the discharge of WordPress 3.5 which got here with tons of amazing features. As we upgraded one web site after one other, we observed a difficulty on one of many websites we handle. The embedded video measurement have been modified, and the embedded movies have been lots smaller. We went within the settings to search out that the choice to specify oEmbed max width and top have been eliminated. In an try to simplify the admin panel, the core staff removed the oEmbed max width and top settings display. On this article, we'll present you how you can set oEmbed max width in WordPress three.5 with $content_width.

What modified? and Why?

Up to now, in your Settings » Media display there was an choice to set the oEmbed max width and top.

Media Settings oEmbed Width

Nicely, this feature is not there in WordPress three.5. The choice was made to make issues easier. There isn't any hurt in auto-enabling oEmbeds in WordPress. If it's not enabled by default, newbies usually get confused. The core devs additionally determined to do away with the oEmbed max width and top fields in favor of utilizing theme’s content material width and make the peak 1.5 occasions the content material width. In case your theme doesn’t have the content material width outlined, then your oEmbed sizes will likely be lots smaller. That is precisely what occurred to one of many websites we handle. The theme that was getting used didn't have $content_width specified.

Easy methods to Repair the oEmbed Width Problem in WordPress three.5

Open your theme’s capabilities.php file, and add the next code:

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

Bear in mind to vary the quantity 600 appropriately on your theme. It's the most width in pixels on your content material space.

When you do that, WordPress will routinely use that for the utmost width of your oEmbed parts (youtube movies, slideshare, and so forth).

Themes