How to add new image size WordPress open

How to add new image size WordPress

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
Tested: WordPress 4.0+, PHP 5.6 +

Before adding new image sizes, you need to make sure that your theme has support enabled thumbnails. This can be done by adding to yours function.php function:

add_theme_support('post_thumbnails');

Now add a new image size this can be done by pasting in function.php

add_image_size( 'my_new_image_size', 500, 400, true );

my_new_image_size – name for new size (!be careful, there are some reserved names that cannot be used they can be viewed in the documentation);
500 – width for new image size;
400 – height for new image size;
true – crop image. If you want the picture not to be cropped but to remain in its proportions change this to false;

More about function add_image_size()

0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation