Search code examples
typo3typoscripttypo3-10.x

TYPO3 Produce images in different sizes


I have this implementation, using it in a page level 2 submenu. Each level 2 menu has multiple subpages. Each subpage has one image. So this implementation produces an image from each page for each submenu. For example, a submenu with 2 subpages will have 2 images (one from each subpage).

1 = FILES
1 {
    references {
        table = pages
        fieldName = media
        data = levelmedia:-1, slide
    }

    begin = 0
    maxItems = 2

    renderObj = COA
    renderObj {
        2 = IMAGE
        2 {
            file {
                //params = -sharpen 50  +profile "*" -quality 100
                import.data = file:current:uid
                treatIdAsReference = 1
                width.optionSplit = 300c|*|400c
                height.optionSplit = 350c|*|450c
            }
        }
    }
}

Would like to have images cropped in different sizes such that image 1 is cut to different dimensions from image 2 and so on.

My ImageMagick installation works perfectly. Am actually cropping single images with it without a hitch.

Without the optionSplit above, the images are cut to size nicely. Unfortunately with the optionSplit it simply outputs the images in their original sizes.

How can I produce different image sizes? My understanding is that optionSplit is the way to go (from the manuals). I read in articles that soureCollection for responsive images use optionSplit. I imagine another way would be to use an image register counter and use CASE to determine how to cut image 1, 2, 3 and so on, but am not familiar with register counters (maybe someone can show me how to do this?). And yet another way would be to use a file/image index number but I've tried looking at the manuals for hours for such a pointer and nowhere is it listed if there's any to help with processing. Anybody know a way to do this?


Solution

  • rendering two consecutive images with different paramters will be difficult in typoscript:
    your optionsplit can not success as in the renderObj you always have only one file. A bad habit of all renderObj.

    on the other hand: there is no property optionSplit. the functionality is build in any wrap property.

    therefore a handling in typoscript could be to concatenate the elements, then split them again, but then use different options in the split renderObj to handle it separately.
    or implement a counter with a register variable, then evaluate the register to set different values.

    easier would be a handling in fluid, where you could use an iterator with the f:forviewhelper, and then do an f:if (for two cases) or an f:switch (for more cases) on {iterator.index} to render individual versions.