Reprocessing images of different versions in Carrierwave

前端 未结 5 1443
甜味超标
甜味超标 2021-02-02 14:12

Using Carrierwave, I created 3 versions of an avatar - an original, a small_thumb and a large_thumb using the following lines:

process :resize_to_limit => [40         


        
5条回答
  •  青春惊慌失措
    2021-02-02 14:46

    You need to call image.cache_stored_file! before calling recreate_versions!

    It's weird because the method itself calls that if the file is cached, but for some reason it wasn't working.

    So that would be something like:

    def reprocess_image
      image.reprocess(crop_x, crop_y, crop_w, crop_h)
      image.cache_stored_file!
      image.recreate_versions!
    end
    

提交回复
热议问题