我正在使用 Amazon 的 S3 进行图像存储,并配置了载波和雾。图像似乎可以正确存储,但是当我有一个“纵向”图像(宽度小于高度)时,它无法正确显示,而是将图像侧向旋转。
任何指向正确方向的指针将不胜感激!
上传者/image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
storage :fog
include CarrierWave::MimeTypes
process :set_content_type
process :resize_to_limit => [420, 0]
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg png)
end
end
显示.html.haml
= image_tag(@idea.image_attachments.first.image.url).to_s
image_attachment.rb
class ImageAttachment < ActiveRecord::Base
require 'carrierwave/orm/activerecord'
attr_accessible :image, :description
belongs_to :image_attachable, polymorphic: true
mount_uploader :image, ImageUploader
end