Sha256: 821e8318e6e278bd929fdf0863d7ae22a180516d6ec82b5ae11f36eea2a3f360

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

module Spree
  class StoreFaviconImage < Asset
    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

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/models/spree/store_favicon_image.rb
spree_core-4.10.0 app/models/spree/store_favicon_image.rb
spree_core-4.9.0 app/models/spree/store_favicon_image.rb