use png for previews

This commit is contained in:
Pete Matsyburka
2024-09-11 16:46:33 +03:00
committed by Oleksandr Turchyn
parent 26ae5f1d80
commit bc4414a368
4 changed files with 23 additions and 16 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ module Templates
preview_image_attachments ||=
ActiveStorage::Attachment.joins(:blob)
.where(blob: { filename: '0.jpg' })
.where(blob: { filename: ['0.jpg', '0.png'] })
.where(record_id: schema_documents.map(&:id),
record_type: 'ActiveStorage::Attachment',
name: :preview_images)
@@ -29,7 +29,7 @@ module Templates
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
first_page_blob = preview_image_attachments.find { |e| e.record_id == attachment.id }&.blob
first_page_blob ||= attachment.preview_images.joins(:blob).find_by(blob: { filename: '0.jpg' })&.blob
first_page_blob ||= attachment.preview_images.joins(:blob).find_by(blob: { filename: ['0.jpg', '0.png'] })&.blob
{
id: attachment.id,