5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 17:46:21 +00:00
panel/app/models/metadata_image.rb

21 lines
362 B
Ruby
Raw Permalink Normal View History

2019-08-06 17:54:17 +00:00
# frozen_string_literal: true
# Define un campo de imagen
2019-11-07 16:08:14 +00:00
class MetadataImage < MetadataFile
2019-08-22 19:13:21 +00:00
def validate
super
2019-08-23 18:24:41 +00:00
errors << I18n.t('metadata.image.not_an_image') unless image?
2019-08-22 19:13:21 +00:00
errors.compact!
errors.empty?
end
2020-08-05 15:29:11 +00:00
# Determina si es una imagen
2019-08-23 18:24:41 +00:00
def image?
2020-08-07 20:49:46 +00:00
return true unless file
2020-08-07 14:15:06 +00:00
filemagic.file(file).starts_with? 'image/'
2019-08-23 18:24:41 +00:00
end
2019-08-06 17:54:17 +00:00
end