Issue Bug New Quiet

#77945responsive IMAGE rendering does not work if inside FILES

Sebastian Mazza 09/14/16, 13:20 updated 10/18/26, 16:20

Description

OptionSplit for config key layout.$layoutKey.source of an IMAGE does not work if the IMAGE is a renderObj of a FILES content element.

The FILES content object resolves all optionSplit strings for the file count.
Therefor, when the IMAGE content object wants to split the layout.$layoutKey for the count of sourceCollection items the optionSplit strings are already resolved but for the wrang thing.

This bug breaks the key feature for responsive image rendering (https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Image/Index.html#cobj-image-layoutkey).

FILES rendering:

$splitConf = $GLOBALS['TSFE']->tmpl->splitConfArray($conf, $availableFileObjectCount);

in
@sysext/frontend/Classes/ContentObject/FilesContentObject.php :: render(), Line: 43@

IMAGE rendering:

$srcLayoutOptionSplitted = $tsfe->tmpl->splitConfArray($conf['layout.'][$layoutKey . '.'], count($activeSourceCollections));

in
@sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php :: getImageSourceCollection() , Line:1678@

TS Example that takes the first image from the page media column:

lib.headerImage = FILES
lib.headerImage {
    references {
        data = levelmedia:-1, slide
    }

    begin = 0
    maxItems = 1

    renderObj = IMAGE
    renderObj {
        file {
            treatIdAsReference = 1
            import.data = file:current:uid
            width = 320c
            height = 133c
        }
        sourceCollection {
            x320 {
                width = 320c
                height = 133c
                srcsetCandidate = 320w
            }
            x640 {
                width = 640c
                height = 267c
                srcsetCandidate = 640w
            }
            x1242 {
                width = 1242c
                height = 517c
                srcsetCandidate = 1242w
            }
        }
        layoutKey = srcset
        layout {
            srcset {
                element = <img src="###SRC###" srcset="###SOURCECOLLECTION###" sizes="100vw" ###PARAMS### ###ALTPARAMS### ###SELFCLOSINGTAGSLASH###>
                # the optionSplits in the next line gets resolved by the FILES renderer and not the IMAGE renderer => missing "," for the last img tag, and and wrong "," at the end for all other img tags
                source = |*|###SRC### ###SRCSETCANDIDATE###,|*|###SRC### ###SRCSETCANDIDATE###
            }
        }
        altText.data = file:current:alternative
        titleText.data = file:current:title
    }
}

Result of this example is a image element with missing “,” inside the srcset attribute.

Reviews 1

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". The changes above were merged or abandoned: read them before you start. How to create a patch

Commit message
[BUGFIX] responsive IMAGE rendering does not work if inside FILES Resolves: #77945 Releases: main

History 910

  1. Benjamin Robinson commented <span data-processor="relativetime" data-value="2016-10-30T12:31:56+00:00" > 10/30/16, 12:31 </span>

    I don’t know how to fix this bug, but i found a workaround:

    source = ###SRC### ###SRCSETCANDIDATE###
    x320 {
        width = 320c
        height = 133c
        srcsetCandidate = 320w,
    }
    x640 {
        width = 640c
        height = 267c
        srcsetCandidate = 640w,
    }
    x1242 {
        width = 1242c
        height = 517c
        srcsetCandidate = 1242w
    }
  2. Sebastian Mazza commented <span data-processor="relativetime" data-value="2016-10-31T11:52:07+00:00" > 10/31/16, 11:52 </span>

    Thank you Ben, for sharing your workaround!

  3. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2017-05-10T23:01:38+00:00" > 05/10/17, 23:01 </span>

    It is still reproducible on the latest master (9.0.0-dev)

  4. Patrick Lenk commented and changed TYPO3 Version 7 8 PHP Version 7.2 <span data-processor="relativetime" data-value="2018-11-16T14:42:38+00:00" > 11/16/18, 14:42 </span>

    Ben Robinson wrote:
    > I don’t know how to fix this bug, but i found a workaround:
    >
    > […]
    >
    > […]

    I can confirm this bug for 8.7.20. The workaround from Ben works!

  5. Stephan grass commented <span data-processor="relativetime" data-value="2024-02-20T09:14:14+00:00" > 02/20/24, 09:14 </span>

    It’s still a bug in TYPO3 11, or possibly TYPO3 12.
    It’s easily manageable with the workaround, but either it’s a bug or the documentation needs updating.

  6. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2024-08-17T16:24:29+00:00" > 08/17/24, 16:24 </span>

    Still valid for both TYPO3 12 and 13 (latest main)

  7. Benni Mack commented and changed status Under Review New <span data-processor="relativetime" data-value="2026-10-18T16:20:13+00:00" > 10/18/26, 16:20 </span>

    hard to fix.