Change the standard youtube wordpress embeddable video size

I just upgraded to Wordpress 3.5, and one interesting feature seems to be that if you copy the Youtube URL directly from the browser and paste it into the message for singles, the video will automatically embed!

However, it’s hard for me to understand why the following (inserted into the standard post) does not work for setting embed sizes: [embed width = "20" height = "106"] https://www.youtube.com/watch?v=IjoxX5dXM8g [/ embed]

I searched around Stackoverflow, and it seems like people were saying that you can adjust the sizes in Settings> Multimedia, but this feature is deprecated. Another person blogging at http://shailan.com/2154/change-wordpress-default-embed-size-using-filters/ suggested adding a filter

function mycustom_embed_defaults($embed_size){ if( is_single() ){ // If displaying a single post $embed_size['width'] = 586; // Adjust values to your needs $embed_size['height'] = 500; } return $embed_size; // Return new size } add_filter('embed_defaults', 'mycustom_embed_defaults'); 

... but adding this to functions.php and changing the width and height to 100, I did not see the difference in the preview.

I'm currently still trying to figure out how to reset the default values ​​for the youtube URL pasted into a Wordpress post without resorting to pasting into the whole iframe, i.e.

 <iframe width="560" height="315" src="http://www.youtube.com/embed/IjoxX5dXM8g" frameborder="0" allowfullscreen></iframe> 
+4
source share
1 answer

Try the following:

 add_filter( 'embed_defaults', 'change_embed_size' ); function change_embed_size() { // Adjust values return array('width' => 100, 'height' => 100); } 
+12
source

Source: https://habr.com/ru/post/1485526/


All Articles