简体   繁体   中英

Carrierwave store original file after creating the version

I have ImageUploader class and i want to save my original image with original size of the image after saving the particular version. Help me to solve this

Uploader

class ImageUploader < IconBase
 process :resize_to_fill => [490,68]

 version :normal do
  process resize_to_fill: [245,34]
  def full_filename(for_file = model.logo.file)
    "avatar1.png"
  end
 end

 def filename
   "avatar.png"
 end
end

Your original size is not saved, because you have process :resize_to_fill => [490,68] in your uploader. To keep original size, you can put this into another version, so your main image will stay unproccessed, like this:

version :large do
  process :resize_to_fill => [490,68]
end

Then you'll have:

uploader.url        # original image
uploader.large.url  # [490,68] version
uploader.normal.url # [245,34] version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM