mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-23 05:24:34 +08:00
Fix tinyMCE images for project export [SCI-10719]
This commit is contained in:
parent
026642cd41
commit
80a2cfeb99
5 changed files with 14 additions and 12 deletions
|
@ -14,7 +14,7 @@ module TinyMceImages
|
|||
before_save :clean_tiny_mce_image_urls
|
||||
after_create :ensure_extracted_image_object_references
|
||||
|
||||
def prepare_for_report(field)
|
||||
def prepare_for_report(field, export_all: false)
|
||||
description = self[field]
|
||||
|
||||
# Check tinymce for old format
|
||||
|
@ -29,15 +29,17 @@ module TinyMceImages
|
|||
)[0]
|
||||
next unless tm_asset_to_update
|
||||
|
||||
tm_asset = tm_asset.image.representation(resize_to_limit: Constants::LARGE_PIC_FORMAT).processed
|
||||
unless export_all
|
||||
tm_asset = tm_asset.image.representation(resize_to_limit: Constants::LARGE_PIC_FORMAT).processed
|
||||
|
||||
width_attr = tm_asset_to_update.attributes['width']
|
||||
height_attr = tm_asset_to_update.attributes['height']
|
||||
width_attr = tm_asset_to_update.attributes['width']
|
||||
height_attr = tm_asset_to_update.attributes['height']
|
||||
|
||||
if width_attr && height_attr && (width_attr.value.to_i >= Constants::LARGE_PIC_FORMAT[0] ||
|
||||
height_attr.value.to_i >= Constants::LARGE_PIC_FORMAT[1])
|
||||
width_attr.value = tm_asset.image.blob.metadata['width'].to_s
|
||||
height_attr.value = tm_asset.image.blob.metadata['height'].to_s
|
||||
if width_attr && height_attr && (width_attr.value.to_i >= Constants::LARGE_PIC_FORMAT[0] ||
|
||||
height_attr.value.to_i >= Constants::LARGE_PIC_FORMAT[1])
|
||||
width_attr.value = tm_asset.image.blob.metadata['width'].to_s
|
||||
height_attr.value = tm_asset.image.blob.metadata['height'].to_s
|
||||
end
|
||||
end
|
||||
|
||||
tm_asset_to_update.attributes['src'].value = convert_to_base64(tm_asset.image)
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<% if my_module.description.present? %>
|
||||
<%= custom_auto_link(my_module.prepare_for_report(:description),
|
||||
<%= custom_auto_link(my_module.prepare_for_report(:description, export_all: export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
base64_encoded_imgs: true) %>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<div class="row module-protocol-description">
|
||||
<% if @settings.dig('task', 'protocol', 'description') && protocol.description.present? %>
|
||||
<%= custom_auto_link(protocol.prepare_for_report(:description),
|
||||
<%= custom_auto_link(protocol.prepare_for_report(:description, export_all: export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
base64_encoded_imgs: true) %>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="text-container ql-editor">
|
||||
<%= custom_auto_link(result_text.prepare_for_report(:text),
|
||||
<%= custom_auto_link(result_text.prepare_for_report(:text, export_all: export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<div class="report-element-body">
|
||||
<% if step_text.text.present? %>
|
||||
<%= custom_auto_link(step_text.prepare_for_report(:text),
|
||||
<%= custom_auto_link(step_text.prepare_for_report(:text, export_all: export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
|
|
Loading…
Add table
Reference in a new issue