Search code examples
typo3typoscripttypo3-7.6.x

Override image tag if it is the first?


I am using TYPO3 7.6 with 'CSS Styled Content'.

What I want to do is override the img tag if it is the first image listed in the content element.

So I have added a custom img tag under tt_content.image.20.1.1.layout.custom

Now how do I override tt_content.image.20.1.1.layoutKey if it is the first image?

Eg:

tt_content.image.20.1.1.layoutKey.override = custom
tt_content.image.20.1.1.layoutKey.override.if {
    value = 1
    equals.field = imageOrderNumber??
}

Or is there another way?


Solution

  • There is a register containing the current image number: register:IMAGE_NUM_CURRENT.

    So it should work like this:

    tt_content.image.20.1.1.layoutKey.override = custom
    tt_content.image.20.1.1.layoutKey.override.if {
        value = 1
        equals.data = register:IMAGE_NUM_CURRENT
    }