Matthijn
Matthijn

Reputation: 3234

Youtube dimensions wordpress

Is it possible to change the default embed dimensions of an youtube (or another video) in Wordpress for your current theme? I've searched for a plugin and some code, but I can't seem to find any.

What I mean is the default embed size used when you just paste an youtube url in an post or page.

Upvotes: 10

Views: 14059

Answers (5)

The currently accepted answer has an example that uses the following shortcode:

[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]

The shortcode [youtube] only works if you have the Jetpack plugin installed.

To make it work with WordPress with no Jetpack you can use the built-in [embed] shortcode like this:

[embed width=640 height=385]http://www.youtube.com/watch?v=0Bmhjf0rKe8[/embed]

Upvotes: 3

gregmatys
gregmatys

Reputation: 2198

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).

via wpbeginner.com

Upvotes: 11

Dean Oakley
Dean Oakley

Reputation: 5636

The media settings have been removed. You can do it with a filter however.

function mycustom_embed_defaults($embed_size){

    $embed_size['width'] = 600; // Adjust values to your needs
    $embed_size['height'] = 500; 

    return $embed_size; // Return new size 
}

add_filter('embed_defaults', 'mycustom_embed_defaults');

Taken from here http://shailan.com/2154/change-wordpress-default-embed-size-using-filters/

Upvotes: 10

Monkeyboy
Monkeyboy

Reputation: 21

They've got rid of the fixed width/height option in the media settings of the new version of Wordpress. Not sure why. It was useful!! Shortcodes don't seem to work either.

Upvotes: 2

xavi
xavi

Reputation: 104

To change the default embed size go to Settings > Media and just set a fixed width/height.

You also have the shortcode

[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]

where you can manually insert width and height as params. This shortcode will overwrite the default WP settings.

Upvotes: 2

Related Questions