Uploaded image for project: 'PlantUML Macro'
  1. PlantUML Macro
  2. PLANTUML-38

Allow setting the alternative text of the generated diagram

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • 2.6
    • 2.5
    • None
    • Unknown

    Description

      Steps to reproduce

      1. Create a page with a PlantUML macro that outputs a PNG, for example:
        {{plantuml}}
        Alice -> Bob : hello
        {{/plantuml}}
        
      2. View the page and inspect the generated image.

      Actual result

      The image has its own URL as alternative text:

      <img src="/xwiki/tmp/plantuml/document%3Axwiki%3ASandbox.WebHome/1932342732.png" alt="/xwiki/tmp/plantuml/document%3Axwiki%3ASandbox.WebHome/1932342732.png"/>
      

      Screen reader users hear an encoded temporary file path instead of what the diagram shows, which fails WCAG 2.2 success criterion 1.1.1 Non-text Content (level A). The macro has no parameter to provide a text alternative: its title parameter is drawn inside the image and never reaches the HTML.

      This happens on xwiki.org, for example in the diagram of the accessibility statement.

      Expected result

      The macro has an alt parameter, whose value becomes the alt attribute of the generated image.

      Technical details

      DefaultPlantUMLRenderer#renderImageBlock returns new ImageBlock(resourceReference, false) without any parameter, so the XHTML renderer falls back to the image URL for the alt attribute. Passing an alt parameter to the ImageBlock when it is set would fix the PNG output.

      Open questions:

      • When alt is not set, should the title parameter be used as a fallback? It is shorter than a full description, but much better than the URL.
      • The SVG output is inlined as raw HTML, so it would need role="img" and an aria-label (or a <title> element) on the <svg> instead of an alt attribute.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Lucas C Charpentier Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: