In WordPress How to change default oEmbed Width Size? Change Dimensions of Embedded Elements

App Shah

Crunchify » WordPress Optimization and Tutorials » In WordPress How to change default oEmbed Width Size? Change Dimensions of Embedded Elements

In WordPress How to change default oEmbed iFrame Width Size?

By default WordPress enables WP Embed code to each page. That means you could embed any of your WordPress post to any other post with just simple URL.

You could just paste a URL under WordPress admin Edit Post section and WordPress will render it with nice Heading, Content and Image. That’s really great addition to WordPress when they released this feature in version 4.4.

On Crunchify, we have disabled this WP Embed feature since long time as we personally don’t have detailed use case and plan to embed post directly into another post.

If you have using WP Embed functionality on your site then you may want to check out on how to Set oEmbed Max Width in WordPress?

oEmbed – How to change default width parameter?

function crunchify_embed_defaults($embed_size){
	$embed_size['width'] = 610;
	$embed_size['height'] = 500;
	return $embed_size;
}
add_filter('embed_defaults', 'crunchify_embed_defaults');

Just put above code to your WordPress theme’s functions.php file.

As you see in above code, I’ve provided Width to 610px which is what I wanted on crunchify.com. Please change it accordingly. Once you set Width for WP Embed posts, height may be overridden by embed_defaults hook to match best for your site layout.

WP Embed & How to change width and size of your Youtube video?

By default when you paste a youtube URL, WordPress renders video on site automatically. It’s so simple, nothing you need to do in order to play youtube video in post.

Code:

https://www.youtube.com/watch?v=s0VmLLxgt9I

Live result: (default size)

Now what if you want to change height and widget of your youtube video? Please use below code and youtube video will render with newly provided height and width.

New Code:

Live Example: (610px width)

Let me know if you have any problem updating Embed code width and height for any of the available shortcodes.

Currently we running out site Crunchify on  WordPress v4.8.1 and it supports all of these below Embeds.

Animoto Kickstarter Spotify
Blip Meetup.com TED
Cloudup Mixcloud Tumblr
CollegeHumor Photobucket Twitter
DailyMotion PollDaddy VideoPress
Facebook Reddit Vimeo
Flickr ReverbNation Vine
FunnyOrDie.com Scribd WordPress plugin directory
Hulu SlideShare WordPress.tv
Imgur SmugMug YouTube
Instagram SoundCloud
Issuu Speaker Deck

2 thoughts on “In WordPress How to change default oEmbed Width Size? Change Dimensions of Embedded Elements”

  1. Hey man

    This code actually don’t work, I know its dates back to 2017.

    The problem could be this brand name crunchify? I changed to our brand name but no luck..what should we insert there

    function crunchify_embed_defaults($embed_size){
    $embed_size['width'] = 610;
    $embed_size['height'] = 500;
    return $embed_size;
    }
    add_filter('embed_defaults', 'crunchify_embed_defaults');

    Reply

Leave a Comment