我在CarrierWave提供的类中尝试使用version :thumb
。但是,当我使用version :thumb
类时,图像有错误,它在url中添加thumb
,破坏图像。使用Carrierwave调整图像大小
<img src="/uploads/course/image/2/thumb_OX50XkO.jpg" alt="Thumb ox50xko">
原始图片链接在url中没有thumb
这个词。
编辑:
型号:
class Course < ApplicationRecord
has_many :course_categories
has_many :categories, :through => :course_categories
has_many :course_locations
has_many :locations, :through => :course_locations
mount_uploader :image, ImageUploader
end
者:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process resize_to_fit: [50, 50]
end
end
分享你的模型你上传/处理版本 –