Reprocessing images in Carrierwave

早过忘川 提交于 2020-07-04 07:24:29

问题


Let's say my model has an image with :thumb and the client wants :tiny and :nano thumbnails.

How do I reprocess all the existing images using a rake task?

I've found a rake task that I thought would do it https://gist.github.com/777788 but it's giving me errors.


回答1:


According to the Carrerwave documentation you can use following commands:

Model.all.each do |model|
  model.image.recreate_versions!
end



回答2:


I wanted to expand on this great answer by Mikhail Nikalyukin

To Reprocess a single version you can do something like this

Model.all.each do |model|
  model.image.recreate_versions!(:version1, :version2)
end

this way if you added a new version you dont have to do all of them again



来源:https://stackoverflow.com/questions/9065737/reprocessing-images-in-carrierwave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!