chore: generate representations coming from ActionText in background
This commit is contained in:
parent
4d0961d3ec
commit
37a018880b
3 changed files with 25 additions and 13 deletions
|
@ -58,6 +58,9 @@ class ImageProcessorJob < ApplicationJob
|
||||||
if attachment.blob.content_type.in?(RARE_IMAGE_TYPES)
|
if attachment.blob.content_type.in?(RARE_IMAGE_TYPES)
|
||||||
attachment.variant(resize_to_limit: [2000, 2000]).processed
|
attachment.variant(resize_to_limit: [2000, 2000]).processed
|
||||||
end
|
end
|
||||||
|
if attachment.record.class == ActionText::RichText
|
||||||
|
attachment.variant(resize_to_limit: [1024, 768]).processed
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ module BlobImageProcessorConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def representation_required?
|
def representation_required?
|
||||||
from_champ? || from_messagerie? || is_a_logo?
|
from_champ? || from_messagerie? || logo? || from_action_text?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -27,6 +27,10 @@ module BlobImageProcessorConcern
|
||||||
attachments.any? { _1.name == 'logo' }
|
attachments.any? { _1.name == 'logo' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def from_action_text?
|
||||||
|
attachments.any? { _1.record.class == ActionText::RichText }
|
||||||
|
end
|
||||||
|
|
||||||
def watermark_required?
|
def watermark_required?
|
||||||
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
|
<% if blob.representable? %>
|
||||||
<% if blob.representable? %>
|
<% representation = blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
|
||||||
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
|
<% if representation.image&.attached? || representation.key.present? %>
|
||||||
<% end %>
|
<figure class="attachment attachment--preview attachment--<%= blob.filename.extension %>">
|
||||||
|
<%= image_tag representation %>
|
||||||
<figcaption class="attachment__caption">
|
|
||||||
<% if caption = blob.try(:caption) %>
|
|
||||||
<%= caption %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<span class="attachment__name"><%= blob.filename %></span>
|
<figure class="attachment attachment--file attachment--<%= blob.filename.extension %>">
|
||||||
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
|
<%= image_tag blob %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</figcaption>
|
</figure>
|
||||||
</figure>
|
<figcaption class="attachment__caption">
|
||||||
|
<% if caption = blob.try(:caption) %>
|
||||||
|
<%= caption %>
|
||||||
|
<% else %>
|
||||||
|
<span class="attachment__name"><%= blob.filename %></span>
|
||||||
|
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
|
||||||
|
<% end %>
|
||||||
|
</figcaption>
|
||||||
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue