Hi devs,
Context
Right now we use this strategy:
- XWiki automatically generates ids based on the content. For example for heading, the id is based on the heading content. For images, the id is based on the image name.
- Pros: Simple to guess and use if you know the algorithm (no long and non-understandable ids like UUIDs in the content, e.g.
123e4567-e89b-42d3-a456-556642440000
) - Cons: If the heading content is modified or the image name is changed, the ids are modified and references to them will break
- The current strategy is that if you need a fixed/permanent id, you use the
{{id}}
macro. For example:{{id name="myheadingid"/}} = Some heading = ... {{id name="myimageid"/}}image:someimage.png
Problem
Some user has raised to me that they’d prefer that we generate ids that do not use the content in the id so that they can rename images and not break references to them (using the {{reference/}}
macro for example).
It’s true that the current strategy is not that great in this regards and will tend to break references or URLs used as permalinks.
Proposal
We could reverse the strategy (possibly with a config option to act as backward compat for admins who want to use the old strategy):
- XWiki automatically generates ids NOT based on the content (a UUID for ex, e.g.
123e4567-e89b-42d3-a456-556642440000
), - Pros: Do not break if the heading content is changed or the image is renamed
- Cons: Cannot be guessed and you need the UI to allow you to get the id easily. For images, we have the lightbox feature. For headings, we’d need to implement some mouse hover to make an icon link appear that could be copied, something like Build Scan® | Develocity This would be useful even without a strategy change BTW.
- If you need a simple id, you could use the
{{id}}
macro. For example:{{id name="myheadingid"/}} = Some heading = ... {{id name="myimageid"/}}image:someimage.png
Additionally I’ve also created Loading... to make it easier to reference an image while in WYSIWYG edit mode.
WDYT?
Thanks