How to change the width of embedded Youtube videos?

In order to fit the embedded Youtube videos to fit your website layout, you need to define the default width for all embeds. In the admin area, go to Appearance > Editor and click the Theme Functions (functions.php) on the list of files on the right. Copy and paste the following line of code to the Theme Function file. You can put it anywhere below the first line which contains the code <?php

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

The 600 in the above code denotes that the default width of all embeds is 600px width. You can change this value to suit your WordPress theme. The height needs not be specified as it will be calculated automatically based on the width of the video.

This setting will also change the width of other embedded elements such as slide files from, tweets on Twitters and Instagram photos, etc.

Reference: WordPress Codex



Please login to post comments.

Login thru Twitter / Facebook


Log in with Facebook