针对在AWS S3上托管活动存储的文章优化了缩略图创建

我正在构建一个博客文章,在文章模型中,我使用aws-sdk和minimagik上传图像。我有一种方法可以获取缩略图的网址,以显示在这样的每篇文章中

class Post < ApplicationRecord
    has_one_attached :post_thumbnails

    def thumb_url(width=200,heigh=200)
      return unless post_thumbnails.attached?
      image_dimension = "#{width}x#{heigh}"
      Rails.application.routes.url_helpers.rails_representation_url(post_thumbnails.variant(
        combine_options: [
          [:resize,"#{image_dimension}^"],[:gravity,"center"],[:crop,"#{image_dimension}+0+0"],[:strip,true],[:quality,"70"],[:repage,nil],[:+,# +repage
          [:distort,"Perspective"]
        ]
      ).processed,only_path: true)
    end
  end

我正在努力寻找获取缩略图URL或仅调整图像大小以减少S3上存储空间的更好方法,实际上我不需要使用缩略图的原始版本

任何人都可以帮助我获得更好的解决方案,以便在通过大小后获得不同的缩略图大小,我知道activeStorage::Variant会获得不同大小的图像activestorage

soei4366 回答:针对在AWS S3上托管活动存储的文章优化了缩略图创建

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3091125.html

大家都在问