Sha256: 48facf69cfd9fba5e0f7b08dd4956e2dc239ac4f705dc3819825e383c5377fb6
Contents?: true
Size: 1.09 KB
Versions: 15
Compression:
Stored size: 1.09 KB
Contents
module Spree class Image < Asset module Configuration module ActiveStorage extend ActiveSupport::Concern included do validate :check_attachment_presence validate :check_attachment_content_type has_one_attached :attachment def self.styles @styles ||= { mini: '48x48>', small: '100x100>', product: '240x240>', large: '600x600>' } end def default_style :product end def accepted_image_types %w(image/jpeg image/jpg image/png image/gif) end def check_attachment_presence unless attachment.attached? errors.add(:attachment, :attachment_must_be_present) end end def check_attachment_content_type if attachment.attached? && !attachment.content_type.in?(accepted_image_types) errors.add(:attachment, :not_allowed_content_type) end end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems