Archived topic
Image size and resize - current options
7 replies · Started by nomadiceman on July 23, 2021
I’d like to add some different sizes of images that are created when I upload them.
I’ve seen snippets from Tom on here, but they are a few years old now
Can you tell me what’s the best current way of adding extra sizes that get created?
What I plan to is upload the largest image size. And I’d like Wordpress to generate smaller sizes. I will require no cropping as I’ll keep the ratios the same. So it’s just smaller sizes with the same ratio’s that’s required
Thanks in advance 🙏
Hi there,
the add_image_size function is still the way to do it:
https://docs.generatepress.com/article/adding-image-sizes/
If you don't want to crop and you may have variable height images then simply add the width value eg.
add_image_size( 'my_500_wide_image_example', 500 );
Perfect. Thanks David I’ll give that a shot 🙏
You're welcome
Hi David,
I got this set up not problem, and can see I can select a different size in the customiser.
Is there a way to be able to select these added sizes in the Block areas. Such as image block etc?
What do I need to do to do that?
Is a plugin recommended for that? I'd prefer not to use a plugin if possible
The additional sizes you added should be available with the Image Block.
You must make sure that the Image has those sizes - if the image was uploaded before the sizes were added then you will need to run the Regenerate Thumbnails to create those sizes.
I believe it did regenerate all images again. Found this code and this seems to work.
Maybe I’ve messed up somewhere with the other code
add_theme_support( 'post-thumbnails' );
add_image_size( 'image-size-test', 640, 335, true ); // 640 width, 335 height, crop
The add_theme_support( 'post-thumbnails' ); shouldn't be required. But if that resolves the issue then leave it in :)