render image as file

pull/502/head
Pete Matsyburka 4 months ago
parent bf2f5b24dc
commit cd477c880c

@ -28,9 +28,9 @@
</div>
<% end %>
</div>
<% elsif field['type'].in?(['image', 'initials', 'stamp']) %>
<% elsif field['type'].in?(['image', 'initials', 'stamp']) && attachments_index[value].image? %>
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy">
<% elsif field['type'].in?(['file', 'payment']) %>
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
<autosize-field></autosize-field>
<div class="px-0.5 flex flex-col justify-center">
<% Array.wrap(value).each do |val| %>

@ -244,9 +244,9 @@
<div class="w-full bg-base-300 py-1">
<img class="object-contain mx-auto" style="max-height: <%= field['type'] == 'signature' ? 100 : 50 %>px" height="<%= attachments_index[value].metadata['height'] %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy">
</div>
<% elsif field['type'].in?(['image', 'stamp']) %>
<% elsif field['type'].in?(['image', 'stamp']) && attachments_index[value].image? %>
<img class="object-contain mx-auto max-h-28" style="max-height: 200px" height="<%= attachments_index[value].metadata['height'] %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy">
<% elsif field['type'] == 'file' || field['type'] == 'payment' %>
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
<div class="flex flex-col justify-center">
<% Array.wrap(value).each do |val| %>
<a target="_blank" class="flex items-center space-x-1" href="<%= attachments_index[val].url %>">

@ -312,8 +312,9 @@ module Submissions
text_align: field_name.to_s.match?(RTL_REGEXP) ? :right : :left,
line_spacing: 1.3, padding: [0, 0, 2, 0]
),
if field['type'].in?(%w[image signature initials stamp])
attachment = submitter.attachments.find { |a| a.uuid == value }
if field['type'].in?(%w[image signature initials stamp]) &&
(attachment = submitter.attachments.find { |a| a.uuid == value }) &&
attachment.image?
image =
begin
@ -340,7 +341,7 @@ module Submissions
composer.image(io, width:, height:, margin: [5, 0, 10, 0])
composer.formatted_text_box([{ text: '' }])
elsif field['type'].in?(%w[file payment])
elsif field['type'].in?(%w[file payment image])
if field['type'] == 'payment'
unit = CURRENCY_SYMBOLS[field['preferences']['currency']] || field['preferences']['currency']

@ -252,7 +252,11 @@ module Submissions
canvas = page.canvas(type: :overlay)
canvas.font(FONT_NAME, size: font_size)
case field['type']
field_type = field['type']
field_type = 'file' if field_type == 'image' &&
!submitter.attachments.find { |a| a.uuid == value }.image?
case field_type
when ->(type) { type == 'signature' && (with_signature_id || field.dig('preferences', 'reason_field_uuid')) }
attachment = submitter.attachments.find { |a| a.uuid == value }

Loading…
Cancel
Save