使用 Carrierwave,我想根据上传的照片类型将照片调整为不同的尺寸
我有一个用户模型和一个帖子模型。用户的照片将被调整为小缩略图,帖子的照片将被调整为大缩略图。
version :smallThumb do
process :resize_to_fill => [100, 100]
end
version :largeThumb do
process :resize_to_fill => [200, 200]
end
如何告诉 Carrierwave 为上传的照片选择哪种尺寸?对于所有上传,它都会调整为小和大吗?
I have a User model and a Post model. A user's photo will be resized to a small thumbnail, and a post's photo will be resized to a large thumbnail.
version :smallThumb do
process :resize_to_fill => [100, 100]
end
version :largeThumb do
process :resize_to_fill => [200, 200]
end
How do I tell carrierwave which size to choose for an uploaded photo? Will it resize to both small and large for all uploads?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建 2 个单独的上传器模型。看起来像这样:
profile_uploader.rb
atached_uploader.rb
user.rb
post.rb
You can create 2 separate uploader models. Would look something like this:
profile_uploader.rb
atached_uploader.rb
user.rb
post.rb