fix(gallery): display pdf previews without ImageMagick and pdftoppm installed in web machines

This commit is contained in:
Eric Leroy-Terquem 2024-10-18 15:02:10 +02:00
parent fcb868c6a8
commit 6888a3da94
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605

View file

@ -2,7 +2,7 @@
module GalleryHelper
def displayable_pdf?(blob)
blob.previewable? && blob.content_type.in?(AUTHORIZED_PDF_TYPES)
blob.content_type.in?(AUTHORIZED_PDF_TYPES)
end
def displayable_image?(blob)
@ -16,8 +16,7 @@ module GalleryHelper
end
def preview_url_for(attachment)
preview = attachment.preview(resize_to_limit: [400, 400])
preview.image.attached? ? preview.processed.url : 'pdf-placeholder.png'
attachment.blob.preview_image.url.presence || 'pdf-placeholder.png'
rescue StandardError
'pdf-placeholder.png'
end