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
|
|
|
|
|
2022-03-08 16:21:13 +00:00
|
|
|
errors << I18n.t('metadata.image.not_an_image') if path? && !image?
|
2019-08-22 19:13:21 +00:00
|
|
|
|
|
|
|
errors.compact!
|
|
|
|
errors.empty?
|
|
|
|
end
|
|
|
|
|
2023-10-09 17:25:32 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
# Determina si es una imagen para web
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
2019-08-23 18:24:41 +00:00
|
|
|
def image?
|
2022-03-04 22:21:48 +00:00
|
|
|
static_file&.blob&.send(:web_image?)
|
2019-08-23 18:24:41 +00:00
|
|
|
end
|
2019-08-06 17:54:17 +00:00
|
|
|
end
|