【问题标题】:Active Storage not resizing images活动存储未调整图像大小
【发布时间】:2021-05-04 19:26:45
【问题描述】:

我正在使用带有 gems 的 Rails 5.2.4 上的活动存储:

# Use ActiveStorage variant
gem 'rmagick', '~> 2.15', '>= 2.15.4'
gem 'mini_magick', '~> 4.8'
gem 'image_processing', '~> 0.2.3'

并尝试

    <%= image_tag photo.image.variant(resize: "1000x1000").processed.service_url, class: 'img-responsive-full' %>
    <%= image_tag photo.image.variant(resize: "1000x1000>").processed.service_url, class: 'img-responsive-full' %>
    <%= image_tag photo.image.variant(resize: "1000>x1000>").processed.service_url, class: 'img-responsive-full' %>

这些方法都不是调整图像大小或强制我想要的 1000x1000 尺寸,我怎么能强制图像是那个大小? (我刚刚从回形针迁移到主动存储)

【问题讨论】:

标签: ruby-on-rails-5 rails-activestorage


【解决方案1】:

添加! 让它工作:

<%= image_tag photo.image.variant(resize: "1000x1000!"), class: 'img-responsive-full' %>

虽然我找不到解释为什么没有它就不能调整大小。通过阅读documentation 似乎它应该可以在没有任何添加的情况下工作。

【讨论】:

    猜你喜欢
    • 2011-02-18
    • 2018-01-28
    • 2022-08-18
    • 2011-01-24
    • 1970-01-01
    • 2011-10-24
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多