Project

General

Profile

Actions

Patch #41919

open

Add width and height to img src

Added by Kota Shiratsuka 2 days ago. Updated 2 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Why do I need it?

Feature #36294: Lazy load inline images

If you read the image lazily, the position of the anchor will shift due to the lazy reading, and the image will not be displayed in the correct position, causing a scroll jump.

What's this patch?

0001-Add-width-and-height-when-img-src.patch
This patch extends the helper parse_inline_attachments to load images with MiniMagick, get their sizes, and add the image sizes to weight= and height=
However, it will not add them if there are specifications such as {width:50%}

0002-Calling-MiniMagick-every-time-is-slow-so-I-m-going-t.patch
However, if there are a large number of inline images, loading them with MiniMagick each time will have a significant impact on performance.

This patch checks the key redmine.attachments.digest in config.redmine_image_cache_store, and if the image is not in the cache, it executes MiniMagick to save it to the cache, and if the image is in the cache, it returns the size of the image stored in the cache.
This means that MiniMagick does not need to be executed again, so the impact on performance is minimal.
The patch is set to production, but if you don't specify it, the default is memory_store.

The format and data stored in redis

[root@redmine ~]# valkey-cli -s /var/run/valkey/valkey.sock keys '*' | grep image_dimensions
image_dimensions:10a3b1ab516e31176798bb1fd952f747e1667e9b208d7d8d697b4535f9ea6178
image_dimensions:9377d274c36a84a7579541fafa525d1c21cee744a519d3194866bed3ca7370bb
image_dimensions:19d029f0ed62c02266d41ae91c77ab914595194045f163fc8e87d235c852a334
image_dimensions:f4c21653c4d6328ad70cd31326f8511678c3ae989703b029e14dc203f1e01ad5
image_dimensions:f981979a919e4fdd187dff1393e2c7e395dee7aeffe94fe273360466546e8cf1
image_dimensions:3c25facbf5e4d324ed943b4305476d4bae02cef90fd7f822a9d9a135f118391d
image_dimensions:198c592e908c4e7ba2d153df0e832a73759fb98d8819f5f0f27dc09aab34d9f1
image_dimensions:b1e1332cc1adb1b95b9768d410c6fb324b60cf04570d0835da75fc23ab2314c5
image_dimensions:2efaf328deb2b81fc2c4386d27d7d259dbc6f172fae66031b6fcaa8ea157f3dc
image_dimensions:8b35b9977232d3c02cfaedab14457a50647aa8bca150da14202f795d6f7a6a19
[root@redmine ~]# valkey-cli -s /var/run/valkey/valkey.sock GET 'image_dimensions:580cc763f5a06d1310d0e58852beae5a01c0f9a37304fabfc8cd8b48344f57a7'
"\x00\x04\b[\x06{\a:\nwidthi\x02 \x03:\x0bheighti\x02\x1e\x03" 


Files

Actions

Also available in: Atom PDF