Discover how to generate custom size thumbnails in WordPress using a simple code snippet.
WordPress creates 3 different thumbnail sizes by default for each image you upload to the media library. In addition, some child themes and plugins also produce their own thumbnails.
No one of them has the right dimensions? You can create a custom thumbnail size on your own.
Please note that this new format will be applied to ALL images you upload to the theme from now on.
Therefore, I recommend you to check the thumbnail sizes you already have available and only implement this tutorial if none of them meet your needs.
Less is more. 😉
Snippet to add custom thumbnails
Add the following fragment at the end of the functions.php file:
You got it (or almost got it).
Important: This snippet only affects images you upload to WordPress after implementation; that is, it does not affect files previously uploaded to the media library.
If you want to get new thumbnails from previous images, use a plugin like Regenerate Thumbnails to create them.
With just one line of code you can get that perfect thumbnail size you need for a specific section of your child theme.
As you can see, generating new thumbnails is very easy.
But remember to check the ones you already have available before creating redundant copies and versions that only serve to overload the web.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂