2014-02-15 23 views
0

我有ImageUploader類,我想在保存特定版本後將圖像的原始大小保存爲原始圖像。幫我解決這個Carrierwave在創建版本後存儲原始文件

上傳

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 

回答

4

您的原稿尺寸不保存,因爲你在你上傳有process :resize_to_fill => [490,68]。爲了保持原來的大小,你可以把這個變成另一個版本,那麼你的主圖像會留unproccessed,像這樣:

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 
相關問題