Ruby on rails 轨道&x2B;回形针-仅限商店调整大小的图像
我的模型看起来像:Ruby on rails 轨道&x2B;回形针-仅限商店调整大小的图像,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,我的模型看起来像: class Photo < ApplicationRecord has_attached_file :image, :styles => { :small => "50x50#" }, :default_style => :small validates_attachment :image,
class Photo < ApplicationRecord
has_attached_file :image,
:styles => { :small => "50x50#" },
:default_style => :small
validates_attachment :image,
content_type: { content_type: ["image/jpeg",
"image/gif", "image/png"] }
end
班级照片{:small=>“50x50#”},
:default_style=>:small
验证_附件:图像,
内容类型:{content类型:[“image/jpeg”,
“image/gif”、“image/png”]}
结束
RAILS存储图像两次:原始大小和
:small
中定义的大小。我只想存储大小调整后的图像。我相信您可以简单地为:original定义一种样式,让回形针将原稿替换为该尺寸
:styles => { :original => '300x168>', :cropped_thumb => {:geometry => "50x50#", :jcrop => true}, ...}
谢谢你,puneet18
此模型可以完成以下任务:
class Photo < ApplicationRecord
has_attached_file :image,
:styles => { :original => "50x50#" },
:default_style => :original
validates_attachment :image,
content_type: { content_type: ["image/jpeg", "image/gif",
"image/png"] }
end
班级照片{:original=>“50x50#”},
:default_style=>:原始
验证_附件:图像,
内容类型:{content类型:[“image/jpeg”,“image/gif”,
“image/png”]}
结束