Project

General

Profile

Actions

Bug #77945

open

responsive IMAGE rendering does not work if inside FILES

Added by Sebastian Mazza over 7 years ago. Updated 2 months ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Image Generation / GIFBUILDER
Target version:
-
Start date:
2016-09-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #59533: OptionSplit cObjNum inside FILES CO does not workClosed2014-06-12

Actions
Actions #1

Updated by Benjamin Robinson over 7 years ago

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
}
Actions #2

Updated by Sebastian Mazza over 7 years ago

Thank you Ben, for sharing your workaround!

Actions #3

Updated by Riccardo De Contardi almost 7 years ago

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

Actions #4

Updated by Susanne Moog over 6 years ago

  • Category changed from Image Cropping to Image Generation / GIFBUILDER
Actions #5

Updated by Patrick Lenk over 5 years ago

  • TYPO3 Version changed from 7 to 8
  • PHP Version set to 7.2

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!

Actions #6

Updated by Stephan grass 2 months ago

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.

Actions

Also available in: Atom PDF