0

I wanted to add a new image size to the theme I have. But the image sizes are not working correctly.

My code:

add_theme_support( 'post-thumbnails' );

add_image_size( 'bch-microsite-slider-image',   1450, 620 );
add_image_size( 'bch-microsite-hero-image',     1450, 315 );
add_image_size( 'bch-microsite-blog-image',     1000, 670, array( 'center', 'center') );
add_image_size( 'bch-microsite-blog-image1',    1000, 670 );
add_image_size( 'bch-microsite-blog-image2',    1000, 650 );
add_image_size( 'bch-microsite-blog-image3',    1000, 620 );

The first two calls were already in the theme, but the apparently never worked right but I never really noticed since I wasn't using them. I added the 3rd call as what I wanted, and the 4th through 6th calls are an experiment.

I used the plugin "Display All Image Sizes" to make sure I wasn't looking at things wrong, but in the Media Library, a newly uploaded image shows the following image sizes: enter image description here

The new sizes never exceed the "large" size, but I don't see a reference to that anywhere in the documentation. Do I have to change the "large" size, or is there some other problem? Any help would be greatly appreciated.

Here are the results of running Regenerate Thumbnails are a single image: enter image description here All the image sizes reported by Regenerate Thumbnails are correct and it generates the correctly sized image files in the uploads folder. However, when selecting the image from the media library, the incorrect sizes are still being shown: enter image description here

When the 3rd size is inserted into a post the code uses the correctly sized file (artwork-1-1000x670.jpg) but uses the size reflected in the image size drop-down list (640 by 429).

0

WordPress has its own built-in image sizes. These sizes are:

thumbnail    // Thumbnail (default 150px x 150px max)
medium       // Medium resolution (default 300px x 300px max)
medium_large // Medium-large resolution (default 768px x null max)
large        // Large resolution (default 640px x 640px max)

The medium-large image size has no height set, meaning that it will only crop the image by width.

You should also regenerate the thumbnails after changing the thumbnail sizes. That might be why you are getting incorrect sizes. You can use the Regenerate Thumbnails to do so.

  • Thanks for the advice. I installed Regenerate Thumbnails and that plugin recognizes the correct sizes, but after running the plugin my images still have the incorrect sizes as shown in screenshot. This shouldn't have mattered since I uploaded new images AFTER I changed the thumbnail sizes as per my original question. – user3147421 Jan 4 '18 at 20:34
0

I think the plugin just adds a trigger which fired at the moment of uploading image. Which means it doesn't work for the uploaded images. As Jack Johansson mentioned you can use the plugin.

  • Yes, that is corrrect. But after I changed the thumbnail sizes, I uploaded new images which do not reflect the correct sizes. – user3147421 Jan 4 '18 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.