IMO the best way to implement that would be to use a custom data attribute. If the custom data attribute is found on the pictures given, the gallery macro generates a <figure> to wrap the image in, and adds the <figcaption> node next to it.
IMO that's enough for a first implementation. On XWIKI-6762 it was mentionned that we could provide finer controls for the caption position, but IMO this is very use-case reliant and I don't think we should add other custom data attributes to support this kind of customization.
An alternative solution would be to make a better picker for images in the gallery macro, where you can select an alt, a caption, and whatever display option we might want... But it would take more time to do and be more complex (meaning more debugging later...).
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.