Changing Oembed max width based type of page

Using the following in your functions.php file should do the trick:

/**
 *  Configure default oEmbed video sizes
 */
function base_oembed_defaults($embed_size) {
    if( is_single() ) {
        $embed_size['width'] = 580;
        $embed_size['height'] = 435;
    }
    return $embed_size;
}
add_filter('embed_defaults', 'base_oembed_defaults');

Add as many WordPress conditional statements as you like to match the desired aspect ratio for each template.

Leave a Comment