I use Image Styles to automatically generate thumbnails (for teasers and views). I have a lot of images, so I end up with a lot of cached thumbnails in the /files/styles directory.

Is it safe to delete the contents of /files/styles without doing anything like clearing the cache in Drupal? My hope is that the thumbnails would be regenerated as needed without issue.

3 Answers 3


It's perfectly safe to delete the files/styles directory. Drupal will regenerate the images the next time someone accesses them.

The Image module defines a menu router item which maps $directory_path . '/styles/%image_style' to image_style_deliver(). image_style_deliver() verifies the generated derivative image exists. If it does, it serves it; otherwise, it calls image_style_create_derivative().


If you have lots of images, deleting everything inside files/styles is not recommended because regenerating this can have a large performance impact.

I usually run a cron to keep it clean:

0 1 * * * find /var/www/<project>/sites/default/files/styles -type f -atime +30 -delete

This only deletes files that were not accessed in the last 30 days.

  • 1
    Why do you need to keep it clean? The only real reason I can see might be to regain more space but in that case you should get more space on your hosting plan. Other than that, deleting images just means a slower request next time someone views one.
    – rooby
    Commented Apr 21, 2013 at 5:33
  • regaining diskspace is indeed the case. Getting more space on your hosting plan is not always free. So, doing a bit of housekeeping can delay the upgrade if you don't want to spend money right away.
    – tvlooy
    Commented Apr 21, 2013 at 18:50

It is safe to delete them. When you clear the image cache all it is doing it deleting the files in the cache directory. If a request for an image cache file is made and the said image cache file does not exist it will be generated as long as the source file still exists. Do not the delete the source files as this will cause errors.

If you can I would suggest installing Drush. It's a command line tool for a large number of Drupal management features. You can clear cache, download modules, backup your database etc...


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.