When changing the theme in WordPress, instead of thumbnails for existing posts, we sometimes see the original images. This is due to the fact that the thumbnails of the required size were not created at the time the image was loaded, and this problem can be solved using the Regenerate Thumbnails plugin.
WordPress has a concept of “image sizes” of which by default there are only three – large, medium, and thumbnail. When uploading images to the media library, WordPress creates a new file for each size, i.e. if you look in your downloads directory, you will often see the following:
Here you can see that three additional files for our sizes were created for the original photo.jpg image. The default sizes in WordPress can be changed in Options → Media and are used when inserting images into posts when creating galleries, and elsewhere.
In addition to the default sizes, WordPress allows you to register additional sizes using themes or plugins. For example, if a plugin displays a widget with popular posts in the sidebar, it can accompany them with images of 50×50 pixels. Or a theme that displays posts in a grid might use 200×200 pixel images.
It is worth noting again that the creation of files of various sizes occurs precisely at the moment the images are loaded into the media library.
Thus, when activating a WordPress theme that uses other sizes, files for those sizes do not exist for previously uploaded images. In this case, WordPress will use as close as possible the available sizes or original images.
This often leads to the fact that our design “floats” or thumbnails on the main page of the site weigh several megabytes.
Regenerate Thumbnails Plugin
The popular Regenerate Thumbnails plugin allows you to update or regenerate all image sizes for all existing files in your WordPress media library. You can do this in the Tools → Regen section. Thumbnails:
If you only want to update sizes for specific images in your WordPress media library, you can do so under Media → Library. Currently, the Regenerate Thumbnails plugin only works in list mode:
Despite the name of the plugin, it updates all registered image sizes, not just thumbnails. After updating the required thumbnails, the Regenerate Thumbnails plugin can be deactivated.
You can update all image sizes with a command wp media regenerate if you are using the WP-CLI utility. You can generate sizes on-demand with the Dynamic Image Resizer plugin, and with the Photon module of the popular Jetpack plugin, you can generate sizes on the fly using the WordPress.com CDN services.WordPress.com
At the very core of WordPress, it will also be possible to generate image sizes on the fly. You can follow the development of this functionality in the WordPress bug tracker.