Anybody else having problems with WordPress 3.5 YouTube embeds???

I just upgraded this blog to 3.5 on a whim as I was writing tonight and although the new Media Manager seems kinda cool, I hate that they removed the max embed size from the Settings menu and are now apparently just deriving the content dimensions for embeds from your theme directly. I mean, it sounds cool in theory, except that WordPress somehow came up with a 640 pixel width out of my theme, whereas I wanted the limit set to 575 px … I’m guessing that maybe it doesn’t take margins into account or something?

Anyways, in the meantime luckily I found a quick, little function that overrides the oEmbed settings and lets you set your own instead – here’s what I ended up throwing into my theme’s functions.php file to get things looking back to normal again…

function example_custom_oembed_dimensions($html, $url, $args) {
 
// Set the width of the video
 $width_pattern = "/width=\"[0-9]*\"/";
 $html = preg_replace($width_pattern, "width='575'", $html);
 
// Now return the updated markup
 return $html;
 
} // end example_custom_oembed_dimensions
add_filter('embed_oembed_html', 'example_custom_oembed_dimensions', 10, 3); 

Leave a Comment

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