Sha256: 1fc6b619df0e2b932c587f63560515b4472b33c982b903b556ac3c321ffdd445

Contents?: true

Size: 528 Bytes

Versions: 3

Compression:

Stored size: 528 Bytes

Contents

module Spina
  module ImagesHelper

    # We wrap some Rails logic inside our own helper method
    # because the resolve directive in ActiveStorage's routes
    # doesn't work outside the main app in 5.2.0.rc2
    def variant(image, options)
      if image.attached? && image.variable?
        variant = image.variant(options)
        main_app.rails_blob_representation_path(variant.blob.signed_id, variant.variation.key, variant.blob.filename)
      else
        "https://placehold.it/100x100.png"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spina-1.1.3 app/helpers/spina/images_helper.rb
spina-1.1.2 app/helpers/spina/images_helper.rb
spina-1.1.1 app/helpers/spina/images_helper.rb