chore(gallery): add activestorage error catching in front

This commit is contained in:
Eric Leroy-Terquem 2024-05-29 11:15:40 +02:00
parent f73a1e1d54
commit ffc0ddc446
No known key found for this signature in database
GPG key ID: ECE60B4C1FA2ABB3

View file

@ -9,13 +9,19 @@ module GalleryHelper
def preview_url_for(attachment) def preview_url_for(attachment)
attachment.preview(resize_to_limit: [400, 400]).processed.url attachment.preview(resize_to_limit: [400, 400]).processed.url
rescue ActiveStorage::Error
'pdf-placeholder.png'
end end
def variant_url_for(attachment) def variant_url_for(attachment)
attachment.variant(resize_to_limit: [400, 400]).processed.url attachment.variant(resize_to_limit: [400, 400]).processed.url
rescue ActiveStorage::Error
'apercu-indisponible.png'
end end
def blob_url(attachment) def blob_url(attachment)
attachment.blob.content_type.in?(RARE_IMAGE_TYPES) ? attachment.variant(resize_to_limit: [2000, 2000]).processed.url : attachment.blob.url attachment.blob.content_type.in?(RARE_IMAGE_TYPES) ? attachment.variant(resize_to_limit: [2000, 2000]).processed.url : attachment.blob.url
rescue ActiveStorage::Error
attachment.blob.url
end end
end end