feat(gallery): add pdf previews
This commit is contained in:
parent
3a4e8b2a32
commit
f3795ebc98
2 changed files with 6 additions and 6 deletions
|
@ -8,17 +8,17 @@
|
||||||
- champ.piece_justificative_file.with_all_variant_records.each do |attachment|
|
- champ.piece_justificative_file.with_all_variant_records.each do |attachment|
|
||||||
.gallery-item
|
.gallery-item
|
||||||
- blob = attachment.blob
|
- blob = attachment.blob
|
||||||
- if blob.content_type.in?(AUTHORIZED_PDF_TYPES)
|
- if blob.previewable? && blob.content_type.in?(AUTHORIZED_PDF_TYPES)
|
||||||
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do
|
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do
|
||||||
.thumbnail
|
.thumbnail
|
||||||
= image_tag("pdf-placeholder.png")
|
= image_tag(attachment.preview(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
||||||
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
||||||
Visualiser
|
Visualiser
|
||||||
.champ-libelle
|
.champ-libelle
|
||||||
= champ.libelle.truncate(25)
|
= champ.libelle.truncate(25)
|
||||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||||
|
|
||||||
- elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
|
- elsif blob.variable? && blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
|
||||||
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
|
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
|
||||||
.thumbnail
|
.thumbnail
|
||||||
= image_tag(attachment.variant(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
= image_tag(attachment.variant(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
- champ.piece_justificative_file.attachments.with_all_variant_records.each do |attachment|
|
- champ.piece_justificative_file.attachments.with_all_variant_records.each do |attachment|
|
||||||
.gallery-item
|
.gallery-item
|
||||||
- blob = attachment.blob
|
- blob = attachment.blob
|
||||||
- if blob.content_type.in?(AUTHORIZED_PDF_TYPES)
|
- if blob.previewable? && blob.content_type.in?(AUTHORIZED_PDF_TYPES)
|
||||||
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do
|
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do
|
||||||
.thumbnail
|
.thumbnail
|
||||||
= image_tag("pdf-placeholder.png")
|
= image_tag(attachment.preview(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
||||||
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
||||||
= 'Visualiser'
|
= 'Visualiser'
|
||||||
|
|
||||||
- elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
|
- elsif blob.variable? && blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
|
||||||
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
|
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
|
||||||
.thumbnail
|
.thumbnail
|
||||||
= image_tag(attachment.variant(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
= image_tag(attachment.variant(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
|
||||||
|
|
Loading…
Reference in a new issue