Sha256: bdce5a249b273594dac7f16fa1f9332495475f8f1f668f4c378861b4113d8b71

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

module Spree
  class StoreFaviconImage < Asset
    if Spree.public_storage_service_name
      has_one_attached :attachment, service: Spree.public_storage_service_name
    else
      has_one_attached :attachment
    end

    VALID_CONTENT_TYPES = ['image/png', 'image/x-icon', 'image/vnd.microsoft.icon'].freeze

    validates :attachment,
              content_type: VALID_CONTENT_TYPES,
              size: { less_than_or_equal_to: 1.megabyte }

    validates :attachment,
              if: :is_png?,
              dimension: { max: 256..256 },
              aspect_ratio: :square

    private

    def is_png?
      attachment.content_type.in?('image/png')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-4.8.3 app/models/spree/store_favicon_image.rb
spree_core-4.8.2 app/models/spree/store_favicon_image.rb