Sha256: 5854b2a7e40a7dc733f86761816c8f0c30a8207323225693456989af77e1e899

Contents?: true

Size: 948 Bytes

Versions: 25

Compression:

Stored size: 948 Bytes

Contents

module Spree
  module Api
    module V2
      module StoreMediaSerializerImagesConcern
        extend ActiveSupport::Concern

        included do
          def self.store_image_url_for(store, attribute_name)
            attachment = store.send(attribute_name)&.attachment
            return unless attachment&.attached?

            url_helpers = Rails.application.routes.url_helpers
            if Spree.public_storage_service_name
              url_helpers.cdn_image_url(attachment)
            else
              url_helpers.rails_blob_path(attachment)
            end
          end

          attribute :logo do |store|
            store_image_url_for store, :logo
          end

          attribute :mailer_logo do |store|
            store_image_url_for store, :mailer_logo
          end

          attribute :favicon_path do |store|
            store_image_url_for store, :favicon_image
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
spree_api-4.10.1 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.10.0 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.9.0 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.8.3 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.8.2 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.7.3 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.6 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.5.5 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.5.4 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.5 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.7.2 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.7.1 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.4 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.7.0 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.3 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.2 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.1 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.6.0 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
spree_api-4.5.3 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb
atkhayar-dev-spree-api-0.0.1 app/helpers/spree/api/v2/store_media_serializer_images_concern.rb