# frozen_string_literal: true # Define un campo de imagen class MetadataImage < MetadataFile def validate super errors << I18n.t('metadata.image.not_an_image') unless image? errors.compact! errors.empty? end # Determina si es una imagen antes de subirla def image? if value['path'].is_a? ActionDispatch::Http::UploadedFile `file --mime-type "#{value['path'].tempfile.path}"` .split(' ') .last .chomp .starts_with? 'image/' else true end end end