Currently if you have a theme that use add_image_size for let say 6 different image size you will have 6 different thumbnail created that will maybe never be used.

With the current version of WordPress what is the best way to make a theme that use 6 or more image size.

What about the wp_get_attachment_image function, if you use an array instead of a thumbnail size, does the image thumbnail get generated on the fly, how does this work?

I would like to use more than 8 different thumbnail sizes without having a lot of un-needed thumbnail in my ftp wp-content folder.

Any advice is welcome

1 Answer 1


When a theme or plugin adds an image size to the list of thumbnails, they will be added to the global $_wp_additional_image_sizes array. This means that every time you upload an image, any additional image sizes will be generated right after the upload is completed.

The answer to your second question is no. WordPress does not generate thumbnails on the fly. They will all be generated after each upload.

If you are going to add a dozen of image sizes and your blog has a lot of images, I suggest you use a plugin that allows you to organize your upload library, or you can use the code from this answer of mine to do it yourself.

  • Thanks for the fast reply. I understand how the add_image_size works, this is what I want to avoid. The thing is that I want to let the user to use a size for their images gallery from 10 preset size, but I don't want to have the 10 size to be generated from the start. I was wondering what is the point of registering a new image size if you can use an array in wp_get_attachment_image Sep 12, 2017 at 12:17
  • But it's not possible. The images must be present in the uploads folder, otherwise they wont work if some one tries to access any of them. What you are looking for can be done by theme options. You can create a theme options page, and then dynamically add the image size based on user's choice.
    – Johansson
    Sep 12, 2017 at 12:21
  • I have a shortcode that let the user choose the size they want to use for the thumbnail. I am wonder if this is needed to have all the image size set in the theme or if I just replace the thumbnail size by the array corresponding of the size the user chooses.. Sep 12, 2017 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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