Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Stale

95004[FEATURE] Add fallback image argument to image ViewHelpers

Benni Mack CR 0 V -1 Hard +407 −113 updated 08/06/26, 22:14

Commit message

f:image and f:uri.image raise an exception when the given image
can not be resolved, for instance because the file has been
removed from the file system, because a referenced sys_file
record no longer exists, or because a variable holds a path that
does not point to a file.

Whether this is fatal depends on the template: in one place an
image is essential for a meaningful result, in another place it
is decorative and its absence should not take down the whole
page rendering. This can not be decided globally, it has to be
decided per ViewHelper call.

Both ViewHelpers now accept an optional "fallback" argument that
defines what to render instead:

  <f:image image="{teaser.image}" width="400"
           fallback="EXT:my_ext/Resources/Public/Placeholder.png" />

The fallback accepts the same values as "src" and is processed
with the same processing instructions, so the placeholder fits
the layout the original image was meant to fill. An empty
fallback renders nothing at all, which allows testing the result
of f:uri.image with f:if instead of guarding the ViewHelper call
itself.

The argument is opt-in: without it, an unresolvable image keeps
raising an exception as before. A fallback that can itself not
be resolved raises an exception too, as this points to a
configuration error in the template.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/04/95004/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/04/95004/1 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V -1 Blocked
    • core-ci -1 CI

Issues 1

Files 5

Review log 23

  1. Benni Mack uploaded patch set 1 07/30/26, 04:47

  2. core-ci voted on patch set 1 V -1 07/30/26, 04:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105650

  3. Benni Mack marked it work in progress 08/06/26, 22:14