Ruby on rails Carrierwave在创建版本后存储原始文件
我有ImageUploader类,我想在保存特定版本后,用图像的原始大小保存我的原始图像。帮我解决这个问题 上传器Ruby on rails Carrierwave在创建版本后存储原始文件,ruby-on-rails,ruby-on-rails-3,carrierwave,Ruby On Rails,Ruby On Rails 3,Carrierwave,我有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.p
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
class ImageUploader[490,68]
版本:正常
处理大小调整到填充:[245,34]
def full_文件名(用于_文件=model.logo.file)
“avatar1.png”
终止
终止
def文件名
“avatar.png”
终止
终止
您的原始大小不会被保存,因为您在上载程序中有过程:调整大小以填充=>[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
您的原始大小不会被保存,因为您在上载程序中有
过程:resize\u to\u 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