Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a script (in Ruby / Rails) that will regenerate all of the thumbnails for my new paperclip styles?

I have an Image model with the following two styles:

:original => ['500x400!'],
:thumb    => ['75x54!',:jpg]

The last style, :thumb, I have just modified the dimensions of to make thubnails larger.

This works great for new images uploaded by users but I'm not sure how to have paperclip loop through all my existing thumbnail images and resize them.

Hoping someone can give some advice about how this to this.

Thanks!

like image 423
Jason Avatar asked Dec 22 '22 16:12

Jason


1 Answers

There is a rake task for that:

rake paperclip:refresh:thumbnails CLASS=YourModel

To be more in control you could also manually reprocess thumbnails for specific instances:

some_model_instances.each do |instance|
  instance.photo.reprocess!
end
like image 125
Julian Maicher Avatar answered Apr 27 '23 06:04

Julian Maicher