diff --git a/app/models/concerns/tiny_mce_images.rb b/app/models/concerns/tiny_mce_images.rb index bd9cbc49e..cc0bcaa88 100644 --- a/app/models/concerns/tiny_mce_images.rb +++ b/app/models/concerns/tiny_mce_images.rb @@ -29,19 +29,24 @@ module TinyMceImages )[0] next unless tm_asset_to_update - variant = tm_asset.image.variant(resize_to_limit: Constants::LARGE_PIC_FORMAT) - resized_asset = ActiveStorage::Variant.new(variant.blob, variant.variation).processed + begin + 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'] + 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 = resized_asset.image.blob.metadata['width'].to_s - height_attr.value = resized_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 = 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(resized_asset) + rescue StandardError => e + Rails.logger.error(e) end - tm_asset_to_update.attributes['src'].value = convert_to_base64(resized_asset) description = html_description.css('body').inner_html.to_s end description