Review main Merged

92387[BUGFIX] Use sprite references in SvgSpriteIconProvider inline output

Eric Harrer CR +2 V +2 Normal +110 −6 updated 01/21/26, 15:18

Commit message

Sprite-based icons were expected to provide a standalone SVG
file (additionally to the sprite) for rendering via inline markup,
causing SVGs contents to be transferred instead of using references
to a cacheable sprite.

To improve the output of inline rendered icons, we now allow
to render sprite renferences using `<use xlink:href>` references,
when no explicit `source` option for standalone rendering is provided.

The core provided icon sprite is adapted to make use of this
improvement.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Benjamin Kott +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1823

  1. Eric Harrer uploaded patch set 1 01/19/26, 15:53

  2. core-ci voted on patch set 1 V +1 01/19/26, 16:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93785

  3. Garvin Hicking commented on patch set 1 01/19/26, 16:13

    does this maybe prevent dark/light mode SVG context switches? see https://review.typo3.org/c/Packages/TYPO3.CMS/+/90861
  4. Eric Harrer commented on patch set 1 01/19/26, 16:32

    Reply

    No, it does not prevent dark/light mode, as SVG sprites are always rendered inline via the `<svg>`-tag. This patch is more about using the `<use>` tag so that the SVG sprite is applied correctly based on the supplied identifier.
  5. Eric Harrer commented on patch set 1 01/19/26, 17:54

    Reply

    Sorry, I have to revise my statement. When SvgSpriteIconProvider is replaced by SvgIconProvider during icon registration, the current patch renders an <img> tag in both the selection field and the new content element wizard, which causes problems with dark/light mode. The actual problem seems to lie in how SvgSpriteIconProvider is rendered.
  6. Eric Harrer commented on patch set 1 01/19/26, 18:08

    Reply

    Should there even be an inline option for SvgSpriteIconProvider? Rendering the entire sprite does not seem useful in any situation. With a sprite, you always want to use only parts of it, right? How about if SvgSpriteIconProvider::generateInlineMarkup simply returns SvgSpriteIconProvider::generateMarkup? “Inline” originally refers to an <svg> tag, which, unlike SvgIconProvider, is already generated by the former.
  7. Eric Harrer uploaded patch set 2 V +1 01/19/26, 18:46

  8. Eric Harrer commented on patch set 2 01/19/26, 18:50

    Reply

    I have now adjusted the return value of SvgSpriteIconProvider::generateInlineMarkup. This allows SVGs to be rendered correctly with both available SVG icon providers without affecting dark/light mode capability.
  9. core-ci voted on patch set 2 V -1 01/19/26, 18:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93795

  10. Eric Harrer rebased onto patch set 3 V -1 01/21/26, 07:23

  11. core-ci voted on patch set 3 V -1 01/21/26, 07:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93918

  12. Eric Harrer uploaded patch set 4 V -1 01/21/26, 10:20

  13. core-ci voted on patch set 4 V +1 01/21/26, 10:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93930

  14. Benjamin Franzke commented on patch set 4 CR -1 01/21/26, 11:52

    I like it, but will improve
  15. Benjamin Franzke commented on patch set 4 01/21/26, 12:06

    The changed test cases show that behavior is changed when a *valid* source is given. The problem is, that the source (as defined in the ticket) is not a correct source. The `source` is expected to be a standalone SVG file, even for sprite icons (not my idea, but that's how it is). We nevertheless like the idea to always use references (since that's supported nowadays, even for coloring), but that means we must not break existing source references. My idea: Use `source`, if provided, but use references, if `source` is omitted. I'll add that to this patch.
  16. Benjamin Franzke uploaded patch set 5 CR -1 V +1 01/21/26, 12:18

  17. Benjamin Franzke commented on patch set 5 01/21/26, 12:18

    Reply

    Done
  18. core-ci voted on patch set 5 V +1 01/21/26, 12:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93944

  19. Garvin Hicking commented on patch set 5 01/21/26, 13:05

    @ben@bnf.dev Does this make https://review.typo3.org/c/Packages/TYPO3.CMS/+/90861 obsolete or complement it (or is completely distinct)? I did not really check both approaches.
  20. Eric Harrer commented on patch set 5 01/21/26, 13:40

    Reply

    It complements. When record icons are registered via SvgSpriteIconProvider, they are now also rendered correctly inline (as explicitly requested in patch #90861), provided that only the “sprite” option is used. For core backend icons that are automatically registered with SvgSpriteIconProvider, the “source” option has therefore been explicitly removed in this patch. SvgSpriteIconProvider is not used anywhere else in the core.
  21. Benjamin Kott commented on patch set 5 CR +1 V +1 01/21/26, 13:48

    Reply

    @garvin@hick.ing it`s a different topic, as described by @info@eric-harrer.de already. will resolve it here.
  22. Benjamin Franzke voted on patch set 5 CR +2 V +2 01/21/26, 13:55

  23. Benjamin Franzke merged patch set 6 01/21/26, 15:18