From af160b3f3fc01f17e7f26ded1351dd8f84987478 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 26 Sep 2026 17:07:47 +0300 Subject: [PATCH] fix edit image --- lib/templates/modify_documents.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/templates/modify_documents.rb b/lib/templates/modify_documents.rb index d10cd97dc..1a0ffa0fc 100644 --- a/lib/templates/modify_documents.rb +++ b/lib/templates/modify_documents.rb @@ -259,20 +259,20 @@ module Templates image = draw_image_redaction(image, ref['redact']) if ref['redact'].present? image = rotate_vips_image(image, ref['rotate'].to_i % 360) - extension, format_args = + extension, content_type, format_args = if attachment.content_type == 'image/jpeg' - ['.jpg', { Q: 90 }] + ['.jpg', 'image/jpeg', { Q: 90 }] else - ['.png', {}] + ['.png', 'image/png', {}] end data = image.write_to_buffer(extension, **format_args) blob = ActiveStorage::Blob.create_and_upload!( io: StringIO.new(data), - filename: attachment.filename.to_s, + filename: "#{attachment.filename.base}#{extension}", metadata: { identified: true, analyzed: true }, - content_type: attachment.content_type + content_type: ) document = template.documents.create!(blob:)