Merge pull request #7763 from artoscinote/ma_SCI_10931

Force ActiveStorage variant recreation when generating reports [SCI-10931]
This commit is contained in:
Martin Artnik 2024-07-30 13:55:56 +02:00 committed by GitHub
commit cc24e22a1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,18 +29,19 @@ module TinyMceImages
)[0]
next unless tm_asset_to_update
tm_asset = tm_asset.image.representation(resize_to_limit: Constants::LARGE_PIC_FORMAT).processed
variant = tm_asset.image.variant(resize_to_limit: Constants::LARGE_PIC_FORMAT)
resized_asset = ActiveStorage::Variant.new(variant.blob, variant.variation).processed
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
width_attr.value = resized_asset.image.blob.metadata['width'].to_s
height_attr.value = resized_asset.image.blob.metadata['height'].to_s
end
tm_asset_to_update.attributes['src'].value = convert_to_base64(tm_asset.image)
tm_asset_to_update.attributes['src'].value = convert_to_base64(resized_asset)
description = html_description.css('body').inner_html.to_s
end
description