How do I refresh AND regenerate all my images in Drupal?How do I refresh AND regenerate all my images in Drupal?

Drupal has its lovely image manipulation tools allowing you to create all the designs and thumbnails you need from one source image via it's Media Styles/Imagecache module.

And while you can flush these styles as you see fit (try the Image Style Flush module if using Drupal 7), you need to wait for someone to request the image for it to recreate itself. This can be a time consuming process and slow down the visitor experience.

There are some home-built scripts and modules out there that will do this for you if you search around the Drupal site for hours, however, there is a much simpler solution:-

Step 1.
Install the views module if it is not already present.

Step 2.
Create a view having a field for each image style you wish to regenerate. Pick the imagecache preset you wish to use. Pay careful attention to your 'Multiple Field Settings' - do you want to regenerate every image for each node, or, do you want just the first one - e.g. is this an intro image, or is it the gallery of images?

Step 3.
Set the view access to admin only. Important this one - you don't want everybody accessing this all the time and overloading your server!

Step 4.
If generating many nodes, it may be worth paginating the display so your browser doesn't crash, set up a say 100 nodes at a time and pager through them.

Step 5.
Save the view and go to the page path you have set up, (if generating a large set of images it may be best to do this at a quiet time) watch your server chug away creating the images and voila, all images regenerated - Simple!

Comments

nice idea

but now there is a module for that :)

https://www.drupal.org/project/imageinfo_cache

Thanks for sharing this

In Drupal 8 there will be a time that you can easily do this with some modules but for now hardly any of them are D8-ready so I am very gratefull for this idea and I'm thinking 'Now, why didn't I come up with this?'.
This solves the problem I had!

Thanks

Post new comment