Replacement for TYPO3\Media\ViewHelpers :uri.image() in prototype?

Hi,
exist an EEL-Replacement (or ts2) to get the url from an image-asset in the prototype declaration, like the View-Helper’s uri.image() for Fluid-Template?
Would like to do some logic stuff, before I pass the path-value trough, to the Fluid-Template.
Even after long search, I can’t find it in the Core, with Google or in Docu :sleepy:. Sorry

Thanks for help
Martin

Hello again,
I’m not sure, but could this be a step to a solution?

src = TYPO3.Neos:ImageUri {
        asset = ${q(node).property('imageSmall')}
    }

If yes, is there the possibility to write this on one line, because I would like to do something conditional like in fluid with:

<f:if condition="{imageSmall}"><f:then>{media:uri.image(asset: imageSmall)} 640w</f:then><f:else> ...

The fluid-template works, but I would like to lock out the logic from Fluid-Template. Maybe there is a way to do something conditional in ts2 like this?

src = ${(q(node).property('smallImage') != '' && q(node).property('smallImage') != null  ? TYPO3.Neos:ImageUri(asset = q(node).property('smallImage')) + ' 640w' : '') + (q(node).property('mediumImage') != '' && q(node).property('mediumImage') != null  ? TYPO3.Neos:ImageUri(asset = q(node).property('mediumImage')) + ' 800w' : '')}
  • Multiline and ImageUrl is working, but I can’t find a conditional concatenation.
  • On the other hand, as I try, I can not find a workable transformation to one line or to another way to concatenate resulting Strings to one big string in a ts2 attribute.
    At the end I would like to have the same result like the fluid-solution:
srcset= "http://www.website.neos/_Resources/Persistent/7d727c4c70441362d4accd8f1fd502d5ff5d5bcc/small.jpg 640w, http://www.website.neos/_Resources/Persistent/medium.jpg 800w, ..."

But maybe there is a total different and much more easy solution, that I not know at all?

Hey,
I don’t know if this is the «best» solution - suggestions are very welcome -, but it works!

  • No logic left in template. All in prototype encapsulated.
  • Workaround for if/else.

Maybe it will help others who drive crazy with endless try and error.

#Vendor.Site/Resources/Private/TypoScript/NodeTypes/XY.ts2

prototype(Vendor.Site:XY) < prototype(TYPO3.Neos:Content){
    additionalAttributes.srcset = TYPO3.TypoScript:Value
    additionalAttributes.srcset.imageSmallSrc = TYPO3.TypoScript:Case {
        exist {
            condition = ${q(node).property('imageSmall') != '' && q(node).property('imageSmall') != null ? TRUE : FALSE}
            element = TYPO3.Neos:ImageUri
            element.asset = ${q(node).property('imageSmall')}
            renderer = ${this.element + ' 640w, '}
        }
        notExist {
            condition = ${true}
            element = TYPO3.Neos:ImageUri
            element.asset = ${q(node).property('image')}
            element.width = 640
            renderer = ${this.element + ' 640w, '}
        }
    }
    additionalAttributes.srcset.imageMediumSrc = TYPO3.TypoScript:Case {
        exist {
            condition = ${q(node).property('imageMedium') != '' && q(node).property('imageMedium') != null ? TRUE : FALSE}
            ...       
        }
    }
    ...
    ...
    additionalAttributes.srcset.@process.1 = ${this.imageSmallSrc + this.imageMediumSrc + ...}
#Vendor.Site/Resources/Private/Templates/NodeTypes/Partials/XY.html

{namespace media=TYPO3\Media\ViewHelpers}
<media:image asset="{image}" alt="{alternativeText}" title="{title}" width="{width}" maximumWidth="{maximumWidth}" height="{height}" maximumHeight="{maximumHeight}" allowUpScaling="{allowUpScaling}" additionalAttributes="{additionalAttributes}" />

Cheers!