2024-05-29 10:54:38 +02:00
|
|
|
module GalleryHelper
|
|
|
|
def displayable_pdf?(blob)
|
|
|
|
blob.previewable? && blob.content_type.in?(AUTHORIZED_PDF_TYPES)
|
|
|
|
end
|
|
|
|
|
|
|
|
def displayable_image?(blob)
|
|
|
|
blob.variable? && blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
|
|
|
|
end
|
|
|
|
|
|
|
|
def preview_url_for(attachment)
|
2024-06-11 16:17:09 +02:00
|
|
|
preview = attachment.preview(resize_to_limit: [400, 400])
|
|
|
|
preview.image.attached? ? preview.processed.url : 'pdf-placeholder.png'
|
2024-06-10 11:29:50 +02:00
|
|
|
rescue StandardError
|
2024-05-29 11:15:40 +02:00
|
|
|
'pdf-placeholder.png'
|
2024-05-29 10:54:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def variant_url_for(attachment)
|
2024-06-11 16:17:09 +02:00
|
|
|
variant = attachment.variant(resize_to_limit: [400, 400])
|
|
|
|
variant.key.present? ? variant.processed.url : 'apercu-indisponible.png'
|
2024-06-10 11:29:50 +02:00
|
|
|
rescue StandardError
|
2024-05-29 11:15:40 +02:00
|
|
|
'apercu-indisponible.png'
|
2024-05-29 10:54:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def blob_url(attachment)
|
2024-06-11 16:17:09 +02:00
|
|
|
variant = attachment.variant(resize_to_limit: [2000, 2000])
|
|
|
|
attachment.blob.content_type.in?(RARE_IMAGE_TYPES) && variant.key.present? ? variant.processed.url : attachment.blob.url
|
2024-06-10 11:29:50 +02:00
|
|
|
rescue StandardError
|
2024-05-29 11:15:40 +02:00
|
|
|
attachment.blob.url
|
2024-05-29 10:54:38 +02:00
|
|
|
end
|
|
|
|
end
|