How to solve small image size thumbnail generation issues in WordPress

Working with images is perhaps one of the most annoying things in WordPress, well, at least for me. Websites with thousands of images are a pain in the ass. Why? Because you have to regenerate thumbnails for newly added image sizes. Let’s not even start with the cases when the regeneration is already over and you realize you have to add another image size!

You probably know that image sizes are defined by add_image_size() function in functions.php file (already reserved names for image sizes in WordPress are thumb, thumbnail, post-thumbnail, medium, large). Here’s an example, from one of my latest projects:

<?php // Image sizes
if ( function_exists( ‘add_image_size’ ) ) {
add_image_size( ‘full-image’, 1920, 1080, true ); //(cropped)
add_image_size( ‘half-image’, 960, 640, true ); //(cropped)
add_image_size( ‘third-image’, 768, 528, true ); //(cropped)
} ?>

As you can see, I have pretty large sizes defined. And guess what! Thousands of images already uploaded to the website are not large enough, simple Regenerate Thumbnails plugin won’t help: during regeneration whenever the plugin sees an image with smaller dimensions than your defined image size it will skip the image, and you won’t get your thumbnails. Same goes to newly uploaded small images.

But having all the right sized images is very important, especially in grid layouts.

Now, you have 2 options: replace all your small images with large ones (a tedious task!) or go upscaling.

Sometimes you have to go the easy way and let the images just upscale. Note, that you will lose in quality. If it’s a client’s website, you can follow the directions below, then let the client know that they need to replace/upload larger images if they want sharper display.

You will need 2 plugins instead of Regenerate Thumbnails.

First find and install Thumbnail Upscale plugin. After installing, all your future small media attachments will be upscaled and cropped automatically, that is, if you set cropping in your add_image_size() function to true, like I have in the example above.

But if you have older images you need to crop, too, install Force Regenerate Thumbnails plugin and run it. The plugin deletes all old image sizes and generates new thumbnails, upscaling if necessary.

Voilà, you now have all the sizes you need!