Review main Merged

87582[FEATURE] Configure default image conversion/preview formats

Garvin Hicking CR +2 V +2 Hard +445 −35 updated 10/20/25, 18:58

Commit message

A new config option:

  `$GLOBALS['TYPO3_CONF_VARS']['GFX']['imageFileConversionFormats']`

is added that allows to define two things:

1) Define a list (key=inputFileExtension => value=outputFileExtension)
   of allowed/supported target conversion formats
   for a TYPO3 instance.

2) Define which file formats get converted to specific output formats
   by default (special array key "default").

This allows forward compatibility to new file formats, and to allow
instance maintainers to use a format like "webp" or "avif" for
all image conversions that do not specify a target fileExtension.

Before, the TYPO3 core internally picked jpeg or png (depending
on use of transparency) without the possibility to influence this
without the use of specific extensions.

Some default file formats are now converted to png instead of jpeg
due to the "default => png" setting. Tests for this are adjusted to
match this new behavior. Preference for png has been made to keep
the option of transparency information. It is recommended for instances
that support writing webp/avif to set default => webp or default => avif
for optimized file sizes.

Based on a patch by Philipp Kitzberger:
https://review.typo3.org/c/Packages/TYPO3.CMS/+/78260

The old `GraphicalFunctions->gif_or_jpg()` method is deprecated
and superseded by
`GraphicalFunctions->determineDefaultProcessingFileExtension()`,
former usages are reported by the extension scanner. The new
replacement method is declared `@internal` and will be
moved to a service class in a follow-up.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 10

Review log 5072

Show 3447 earlier messages
  1. Garvin Hicking uploaded patch set 1 12/21/24, 17:41

  2. core-ci voted on patch set 1 V -1 12/21/24, 17:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71527

  3. Garvin Hicking uploaded patch set 2 V -1 12/21/24, 18:41

  4. core-ci voted on patch set 2 V -1 12/21/24, 18:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71529

  5. Garvin Hicking uploaded patch set 3 V -1 12/21/24, 18:59

  6. core-ci voted on patch set 3 V -1 12/21/24, 19:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71530

  7. Garvin Hicking uploaded patch set 4 V -1 12/21/24, 20:27

  8. core-ci voted on patch set 4 V +1 12/21/24, 20:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71531

  9. Garvin Hicking marked it work in progress 12/30/24, 00:05

  10. Garvin Hicking uploaded patch set 5 V +1 01/03/25, 20:24

    Adapt patch for merged pre patches
  11. Garvin Hicking marked it ready for review 01/03/25, 20:25

  12. core-ci voted on patch set 5 V +1 01/03/25, 20:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71879

  13. Garvin Hicking commented on patch set 5 CR -1 01/04/25, 10:18

    config option with pseudo-array syntax is too dirty. We should find a way to make a proper array notation possible in the install tool gui (to not require editing the file manually). Should/could be part of further site config streamlining?
  14. Garvin Hicking uploaded patch set 6 CR -1 V +1 01/05/25, 23:31

    Set config array with speaking keys and adjust tests
  15. core-ci voted on patch set 6 V -1 01/05/25, 23:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71938

  16. Garvin Hicking uploaded patch set 7 V -1 01/06/25, 00:22

    Satisfy PHPStan
  17. core-ci voted on patch set 7 V +1 01/06/25, 00:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71939

  18. Garvin Hicking uploaded patch set 8 V +1 01/06/25, 00:33

    Remove old code fork
  19. core-ci voted on patch set 8 V +1 01/06/25, 00:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71940

  20. André Buchmann commented on patch set 8 01/27/25, 09:24

    Awesome! I'm looking forward to this feature. I like the idea to have it globally configurable and even to be able to define a mapping for each file type.
  21. Benni Mack marked it work in progress 03/22/25, 13:06

  22. Garvin Hicking marked it ready for review 04/22/25, 20:13

  23. Garvin Hicking marked it work in progress 04/22/25, 20:14

  24. Garvin Hicking uploaded patch set 9 V +1 07/07/25, 09:54

  25. core-ci voted on patch set 9 V +1 07/07/25, 10:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81403

  26. Garvin Hicking marked it ready for review 07/07/25, 10:16

  27. Garvin Hicking updated the commit message in patch set 10 V +1 07/07/25, 10:17

  28. core-ci voted on patch set 10 V +1 07/07/25, 10:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81405

  29. Simon Schaufelberger commented on patch set 10 07/07/25, 11:30

    EnvironmentController.php:1187

    I wonder why this is needed as on other places it is not.
  30. Garvin Hicking commented on patch set 11 V +1 07/07/25, 11:53

    Published edit on patch set 10.
  31. Garvin Hicking commented on patch set 11 07/07/25, 11:54

    EnvironmentController.php:1187 Reply

    True, thanks for noticing; this was to circumvent a bug in PHPSTorm. I've remove it. :)
  32. core-ci voted on patch set 11 V +1 07/07/25, 12:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81415

  33. Oliver Hader commented on patch set 11 07/07/25, 20:38

    GraphicalFunctions.php:703

    Can be deprecated in this patch as well, adding an and additional deprecated.rst file.

    GraphicalFunctions.php:738

    This assignment in `$config` seems to be static and could be generated in the constructor already.

    GraphicalFunctions.php:739

    This could be filtered in `$map` already, e.g. ``` $map = array_filter($map, is_string(...)); ```

    Feature-93981-SpecifyDefaultImageConversionProcessingFormat.rst:53

    Those are located in `['SYS']` (`textfile_ext` and `mediafile_ext`)
  34. Garvin Hicking uploaded patch set 12 V +1 07/08/25, 08:59

  35. Garvin Hicking commented on patch set 12 07/08/25, 09:01

    GraphicalFunctions.php:703 Reply

    Done

    GraphicalFunctions.php:738 Reply

    I first wanted the method to be isolated on its own and not introduce new member properties into this already "spammy" class. I've refactored it accordingly, but not too sure if this is really better?

    GraphicalFunctions.php:739 Reply

    I'm an oldschool-foreacher, but I've refactored this into an array_walk now :)

    Feature-93981-SpecifyDefaultImageConversionProcessingFormat.rst:53 Reply

    Oh, thanks for noticing!
  36. core-ci voted on patch set 12 V +1 07/08/25, 09:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81476

  37. Garvin Hicking rebased onto patch set 13 V +1 07/26/25, 19:28

  38. core-ci voted on patch set 13 V +1 07/26/25, 19:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82362

  39. Garvin Hicking commented on patch set 13 08/12/25, 08:51

    GraphicalFunctions.php:738 Reply

    Done
  40. Christian Kuhn voted on patch set 13 CR +1 V +1 08/13/25, 19:55

  41. Benni Mack commented on patch set 13 CR -1 08/13/25, 20:11

    will have a more detailed look - please give me a bit of time for this.
  42. Simon Schaufelberger commented on patch set 13 08/13/25, 21:00

    GraphicalFunctions.php:766

    if you say, this is the new API method for gif_or_jpg, this method should not be internal.
  43. Garvin Hicking commented on patch set 13 08/13/25, 21:13

    Reply

    Happily so. Also need/want to reel in 89373: [BUGFIX] Improve GUI-managed map/list | https://review.typo3.org/c/Packages/TYPO3.CMS/+/89373 before this can get merged.
  44. Benni Mack uploaded patch set 14 CR +1 V +1 09/01/25, 15:16

  45. Garvin Hicking uploaded patch set 15 09/01/25, 15:19

  46. Garvin Hicking uploaded patch set 16 09/01/25, 15:21

  47. Garvin Hicking uploaded patch set 17 09/01/25, 15:22

  1. core-ci voted on patch set 14 V +1 09/01/25, 15:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84169

  2. core-ci voted on patch set 15 V -1 09/01/25, 15:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84171

  3. Benni Mack commented on patch set 17 09/01/25, 15:29

    GraphicalFunctions.php:404

    sounds like we should do this as a separate change / fix to also do this in v13? (also above, where we have the "Special case or AFIF format" a few lines above)

    DefaultConfiguration.php:48

    if the default is png, do we need this line? Idea (not thought-through): We could have the imageProcessing as full list: -> jpg => jpg etc. -> bmp => png etc. and remove imagefile_ext completely? don't know what's best. OTOH if we leave it like this, I'd recommend finding a better option for "imagefile_defaultProcessing" (I see "_" and snake-case in the same option :D). Because: this is partially "default" (if not overridden), but due to the incomplete list (and the fallback to "default" for non-defined options such as "bmp" or "pdf" that's a bit more complex? naming idea: "imageFileConversionFormats" and "defaultImageFileConversionFormat => "png" (= 2 new options)

    DefaultConfiguration.php:124

    should we do this separately?
  4. core-ci voted on patch set 17 V +1 09/01/25, 15:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84174

  5. core-ci voted on patch set 16 V -1 09/01/25, 15:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84173

  6. Garvin Hicking commented on patch set 17 CR -1 09/12/25, 12:09

    Needs merge conflict address.

    GraphicalFunctions.php:404 Reply

    I was a bit afraid to possibly break fallback handling of things like EXT:webp or so in v13. I would rather only do this in main for now...

    GraphicalFunctions.php:766 Reply

    Done

    DefaultConfiguration.php:48 Reply

    I mainly inserted this for "format completion" so that it's obviously, explicitly configured. Dropping imagefile_ext would have larger impact. I would like to maybe do that as a follow-up patch for this, if we have time left to do this as a breaking change. It would make this patch a lot larger and harder to review/get through. I like "imageFileConversionFormats" and will implement this. Thank you!

    DefaultConfiguration.php:124 Reply

    Actually this was done thanks to the MIME-stuff. When rebasing it will go away.
  7. Garvin Hicking commented on patch set 17 09/12/25, 12:16

    Reply

    The patch above is now in! <3
  8. Garvin Hicking uploaded patch set 18 CR -1 V +1 09/26/25, 06:44

  9. Garvin Hicking commented on patch set 18 09/26/25, 06:46

    rebased + updated naming

    DefaultConfiguration.php:124 Reply

    Done
  10. core-ci voted on patch set 18 V +1 09/26/25, 06:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85568

  11. Benni Mack commented on patch set 18 09/30/25, 15:41

    GraphicalFunctions.php:404 Reply

    Done

    DefaultConfiguration.php:48 Reply

    go ahead
  12. Garvin Hicking commented on patch set 18 09/30/25, 16:00

    (forgot to mark as resolved, option is renamed) Ready for review! 🥹

    DefaultConfiguration.php:48 Reply

    Done
  13. Garvin Hicking uploaded patch set 19 V +1 10/10/25, 13:01

  14. Garvin Hicking commented on patch set 19 10/10/25, 13:05

    DefaultConfiguration.php:48 Reply

    I've pushed the renaming now properly. Let me think a bit more about extracting a "defaultImageFileConversionFormat" option instead of having it "merged" in one option. The benefit I see from a single option with "magic" keys is that in the future we might want to have other/more magic keys like "default_web", "default_export", "default_mobile" or so, which could allow some more fine-grained management instead of just a single parameter. But magic keys of course bring other issues. Maybe you can test if this approach generally works for your use cases you outlined, and then we can wrap up this implementation detail.
  15. core-ci voted on patch set 19 V +1 10/10/25, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86402

  16. Benni Mack rebased onto patch set 20 V +1 10/16/25, 19:16

  17. core-ci voted on patch set 20 V +1 10/16/25, 19:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86835

  18. Garvin Hicking commented on patch set 21 V +1 10/16/25, 19:35

    Published edit on patch set 20.
  19. Garvin Hicking updated the commit message in patch set 22 10/16/25, 19:36

  20. core-ci voted on patch set 21 V +1 10/16/25, 19:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86840

  21. core-ci voted on patch set 22 V +1 10/16/25, 19:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86841

  22. Benni Mack voted on patch set 22 CR +1 V +1 10/18/25, 21:11

  23. Benni Mack commented on patch set 22 10/18/25, 21:12

    GraphicalFunctions.php:100 Unresolved

    I think the variable name is wrong but as we plan to refactor this, I see no problem with it for the time being. Hint: It's not a "preview".
  24. Georg Ringer voted on patch set 22 CR +2 V +2 10/20/25, 18:58

  25. Georg Ringer merged patch set 23 10/20/25, 18:58