Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Create Additional Image Sizes in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Create Additional Image Sizes in WordPress

Last month there was a huge vulnerability spotted in a famous image resizing script known as TimThumb. Since then the community has collaborated and fixed the issues. While TimThumb is a viable option, we believe that WordPress theme developers should focus on using the core functions rather than relying on third party scripts. In this article we will show you how to add additional image sizes in WordPress.

WordPress has a built-in feature Post Thumbnails aka Featured Images. There is also a built-in function add_image_size() which lets you specify image sizes and give you the option to crop. Using these core functions in your theme can essentially eliminate the need of a third party script like TimThumb in most cases.

Registering Additional Image Sizes for your Theme

You will need to start by adding the support of post thumbnails by placing the following code in your theme’s functions.php file:

add_theme_support( 'post-thumbnails' );

Once you enable the support for post thumbnails, you can now use the functionality of registering additional image sizes with the function add_image_size(). The usage of add_image_size function is like this: add_image_size( ‘name-of-size’, width, height, crop mode );

Example code can look like:

add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode
add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode
add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode

Now if you notice, we have specified three different sort of image sizes. Each has different modes such as hard crop, soft crop, and unlimited height. So lets cover each example and how you can use them for your benefits.

Hard Crop Mode – As you notice, there is a value “true” added after the height. That true value is telling WordPress to crop the image to the size that we have defined (in this case 120 x 120px). This is the method we use a lot in our theme designs to make sure everything is proportionate and our design is not breaking. This function will automatically crop the image either from the sides or from the top and bottom depending on the size. The downside of hard cropping is that you cannot control which part of the image is displayed.

Correction by Mike Little – When you have uploaded an image and before you insert into post, you can click on ‘edit image’ and from there change the thumbnail or the whole image, scale, rotate, or flip the image , and for the thumbnail select the exact portion of the image you want.

Soft Crop Mode – By default soft cropping mode is turned on this is why you do not see any additional value added after the height. This method resizes the image proportionally without distorting it. So you might not get the dimensions that you wanted. Usually it matches the width dimension and the heights are different based on each image’s proportion. An example display would look like this:

Soft Crop Example

Unlimited Height Mode – There are times when you have super long images that you want to use in your design, but you want to make sure that the width is limited. The main use we find for this sort of image size is on infographic posts. Infographics tend to be very long and full of information. Hard cropping such image on a single post page is not a great idea. But by nature infographics are wider than the content width. So what you can do is specify a width which will not break your design while leaving the height to be unlimited, so all of infographic can be shown without any distortion. An example display would look like this:

Unlimited Height Mode Example

Displaying additional image sizes in your WordPress theme

Now that you have added the functionality for the desired image sizes lets take a look at displaying them in your WordPress theme. Open the theme file where you want to display the image and paste the following code:

<?php the_post_thumbnail( 'your-specified-image-size' ); ?>

Note: This bit of code must be pasted inside the post loop.

That’s all you really have to do to display the additional image sizes in your WordPress theme. You probably should wrap it around with the styling that fits your need.

Regenerating Additional Image Sizes

If you are not doing this on a brand new site, then you probably will have to regenerate thumbnails. The way add_image_size() function works is that it only generates the sizes from the point it was added into the theme. So any post images that were added prior to the inclusion of this function will not have the new size. So what we need to do is regenerate the new image size for older post images. This is made easy by the plugin called Regenerate Thumbnails. Once you install and activate this plugin, a new option is added under the menu: Tools » Regen. Thumbnails

Regenerate Thumbnail Plugin Screen

Click Regenerate Thumbnail icon and let the plugin do its job.

Another plugin that can do this job is Simple Image Sizes.

Enabling Additional Image Sizes for your Post Content

Even though you have enabled image sizes in your theme, the usage is limited only to your theme which does not makes any sense. All image sizes are being generated regardless, so why not make it available for the post author to use it within the post content. You can do this by using a plugin called Simple Image Sizes.

Once you install and activate this plugin new options will be added on your Settings » Media page. You will see a list of sizes that you defined in your theme. All you have to do is check the box that says “Show in post insertion”.

Post Insertion for Additional Image Sizes

Once you check this box, additional sizes will be available for your author to use in the post content.

Additional Image Sizes for Posts

Notice in the image above, we have all the image sizes that we defined in our theme available for our authors to use in the post content if they desire.

Simple Image Sizes plugin also lets you create custom image sizes directly from the WordPress dashboard.

We believe this method should be added under best practices for all WordPress theme developers. What are your thoughts?

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Sakshi says:

    I write this code can.
    Actually i want to set the post thumbnail size for the banner image.Which i was uploading through featured image in the background please suggest me.

  2. Aakash says:

    I m new in wordpress,and accept i have many problems,and the first is,i created lot of post in wordpress,suppose A B C D,and when i update this in my website they look like first is D and then c and then b and then a means when i upload first they are show in last.if any solution that first they look in series not DCBA like ABCD…plz help

  3. Daniel Knoflicek says:

    awsome… so helpfull for a lot of gallery plugins…

  4. Lavinia Manzanarez says:

    Excellent! I read the use of this function on the Codex of WordPress but sometimes I need a step by step thing, thank you!

  5. WPBeginner Staff says:

    Yes it is possible.

    • Farmer John says:

      I too want to do the same as Ali Rohan wants to do. can you kindly elaborate pleas.. ‘coz i tried to implement the method explained by you but could not succeed. I can’t understand where I am doing wrong. How do I link the text of resolution to image file?

  6. Ali Rohan says:

    Thanks for nice article.
    I wanna start a wallpapers website in wordpress so is it possible that when i upload one big wallpaper then it auto resized to many resolutions for users. For example when i upload 1920×1280 wallpaper then it must be resized to 1024×768, 800×600 etc resolution … so users can easily view and download desired size wallpaper ?

  7. Aayush says:

    Hi Dear. i need your urgent help. i have a problem with the images size. actually i am using a plugin WP Gallery Custom Links. i have uploaded lot of images in a post but every images has a different height and width so they are appearing with different different sizes. i want to set them with the same size which i want to set. please tell me any idea to solve this problem.

  8. Here says:

    I just needed to say thanks for saying this. You’re right on.|

  9. Shoaib says:

    Excellent explanation

  10. Andrew says:

    I’ve set this up and it’s working splendidly minus the suggestion MIKE LITTLE made above – the thumbnail is changed and it shows up that way in the backend in the media gallery – but on the frontend where my loop is – the image thumb is still what WP defaults to – i’ve even run REGEN THUMBS and it still doesn’t fix the issue – anyone else having this problem or know the fix???

    • WPBeginner Support says:

      Look at your loop and use <?php the_post_thumbnail('your-specified-image-size'); ?> instead of the_post_thumbnail()

  11. Tomasz says:

    Nice tutorial!
    Please check out the plugin which allows to manually crop the registered image sizes:

    • WPBeginner Support says:

      Thanks, looks like a nice plugin. We will look into it.

    • Marc C says:

      Good tutorial – many thanks WPBEGINNER.

      I too was having the problem of not being able to crop the new registered image sizes but the plugin posted by TOMASZ does the job nicely – thanks TOMASZ!

  12. Robbe Clerckx says:

    Still helpfull after all this time :). Thank you.

  13. Danny says:

    Thank you for this very clear and helpful tutorial. It saved me a lot of time since the WP documentation is very cryptic.

  14. lydia karanja says:

    I have a wordpress account but I did not know how to manage it but now I know all thanks to this tutorial, thank you very much for helping people understand more on how to create and manage their websites.

  15. andy19at says:

    @jezThomp Great if your images work ;)

  16. mikelittle says:

    You say: “The downside of hard cropping is that you cannot control which part of the image is displayed.” Not true.

    When you have uploaded an image and before you insert into post, you can click on ‘edit image’ and from there change the thumbnail or the whole image, scale, rotate, or flip the image , and for the thumbnail select the exact portion of the image you want.

    • wpbeginner says:

      @mikelittle Thanks for the correction Mike. Just edited the article :)

      • clelandillustration says:

        I can’s seem to get the custom crop to work for new image sizes. The custom crop will work for the default “thumbnail” size version, but that crop won’t apply to new image sizes. It seems the crop is still uncontrollable for custom image sizes.

    • Brent Norris says:

      good insight into the edit flow…

  17. TdGon says:

    Good article ..and photos to go along with it too…nice. I saw in a few places how to do this but they did not explain it as well as you do here. I am off to try it out.

    Thanks a lot ! (0.o)

  18. PaulDeWoutersd'Oplinter says:

    excellent explanation for a confusing topic. and very useful plugin

  19. mssbee says:

    Great tutorial! Thanks for explaining the different crop options. It really helped me to understand how they work.

  20. tjhakan says:

    Nice tutorial. good job

  21. defries says:

    Nice round up of what can be done with just the default featured image feature. One extra tip: you can also set the width of your content area as a featured image and define that same width in Settings > Media. This way you can select a featured image to use in your theme and it will be automatically the maximum size of the content area.

    Also great having those values in there for <a href=””>oEmbed</a>.

  22. Ordinary Randomness says:

    Thanks for this tutorial, I was wondering why sometimes I had images that were not cropping to the size I had coded.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.