我有ImageUploader类,我希望在保存特定版本后保存原始图像的原始大小。帮我解决这个问题
上传
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
答案 0 :(得分:4)
您的原始尺寸未保存,因为您的上传器中有process :resize_to_fill => [490,68]
。要保持原始大小,您可以将其放入另一个版本,这样您的主图像将保持未处理状态,如下所示:
version :large do
process :resize_to_fill => [490,68]
end
然后你会:
uploader.url # original image
uploader.large.url # [490,68] version
uploader.normal.url # [245,34] version