Hello all,
We currently have a limitation regarding the image style when the image is wrapped in a figure
element.
The image style is attached to the image, and not to the figure. Hence, it’s not possible to define a CSS selector to keep the figures style consistent.
Know use cases are:
- Define a given width for the captions
- Add a border to the figure containing the image (e.g., to have a frame around the image and its caption)
Currently in XS, there is two way to produce a figure tag:
- Using the image figure with caption
[[Caption>>Doc@image.png]]
- Using the
figure
macro and placing an image inside
Functional proposal
Search for the first image contained in the figure
.
If it exists, move the data-xwiki-image-style*
attributes from that image to the figure (if other images exists, the first one takes priority)
Technical proposal
Constraints:
- Need to be applied on the XDOM as the image figure with caption and the figure macro are not working in the same way (let alone other ways from other extensions)
- Need to be defined in the
xwiki-platform-image-style
module
Given those constraints, I propose to implement this as a Transformation.
Pros:
- easy to implement and test
Cons:
- The
rendering.transformations
key fromxwiki.properties
needs to be maintained:- By adding the new transformation on upgrade
- By removing it if the image style extension is uninstalled
Other solutions I considered required:
- anticipation (i.e., ad-hoc generic code in the transformation modules to allow the image style extension to define it own behavior)
- duplication since the code of the image figure caption and the figure macro has nothing in common until the transformation steps
WDYT?