Image displaying sideways

2019-09-02 03:19发布

I am using CarrierWave to upload an image. The image uploads fine. But any vertical image (only vertical images) displays sideways. How can I fix this?

    <div class="row">
        <div class="profile_picture">
            <%= image_tag @user.attachment.url %>
        </div>
    </div>

the image tag turns into:

<img src="/uploads/user/attachment/23/CIMG6610.JPG" alt="Cimg6610">

CSS:

.profile_picture {
    max-width: 100%;
    img {
        max-width: 100%;
    }
}

if I look at the upload directly in the browser "localhost:3000/uploads/user/attachment/23/CIMG6610.JPG" it displays correctly

1条回答
我命由我不由天
2楼-- · 2019-09-02 04:13

It seemed to be an issue with the upload. Adding this to my Uploader fixed the issue.

  process :auto_orient

  def auto_orient
    manipulate! do |img|
      img = img.auto_orient
    end
  end

Thanks @JohnDevelops

查看更多
登录 后发表回答