Sha256: 2a57107aab5472dfdcf00eefad9d81c5d76339bcdc2e22a85bd027ccb195b93f

Contents?: true

Size: 561 Bytes

Versions: 9

Compression:

Stored size: 561 Bytes

Contents

module Spree
  module ImageMethods
    extend ActiveSupport::Concern

    def generate_url(size:, gravity: 'center', quality: 80, background: 'show')
      return if size.blank?
      size = size.gsub(/\s+/, '')

      return unless size.match(/(\d+)x(\d+)/)

      polymorphic_path(attachment.variant(
        gravity: gravity,
        resize: size,
        extent: size,
        background: background,
        quality: quality.to_i
      ), only_path: true)
    end

    def original_url
      polymorphic_path(attachment, only_path: true)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_core-4.3.3 app/models/concerns/spree/image_methods.rb
spree_core-4.4.1 app/models/concerns/spree/image_methods.rb
spree_core-4.3.2 app/models/concerns/spree/image_methods.rb
spree_core-4.4.0 app/models/concerns/spree/image_methods.rb
spree_core-4.4.0.rc2 app/models/concerns/spree/image_methods.rb
spree_core-4.3.1 app/models/concerns/spree/image_methods.rb
spree_core-4.4.0.rc1 app/models/concerns/spree/image_methods.rb
spree_core-4.3.0 app/models/concerns/spree/image_methods.rb
spree_core-4.3.0.rc3 app/models/concerns/spree/image_methods.rb