I have a Drupal site that has around 24 image styles defined. The problem I'm having is the files directory seems to be building up a huge amount of files.

If I upload an image, does Drupal automatically created a version for each of the 24 styles, or should it only create the relevant size if it's specifically requested within the code?

2 Answers 2


Derivative images are created on-the-fly, when they're first requested via HTTP, or when image_style_create_derivative() is invoked manually for the relevant image/style name.

They're not generated en-masse when a file is first uploaded, unless you have a contrib/custom module installed which provides that functionality.


Drupal only creates the file when it's needed.

The way this works is a url is generated, eg. /sites/default/files/styles/public/somestyle/beach.jpg. The first time this url is called, the file doesn't exist.

Due to Drupal's url handeling, Drupal will chop of parts at the end until it has a hit, in this case /sites/default/files/styles will be caught by the hook_menu of the image module. It will get public, somstyle and beach.jpg as parameters.

Based on these parameters, the image module creates the image.

Your Answer

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

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