[Open Editor]) in a fluid template? All I can co" /> [Open Editor]) in a fluid template? All I can co" /> [Open Editor]) in a fluid template? All I can co"/>

How to get cropped image dimensions in a Fluid template in Typo3 v8

1.6k Views Asked by At

Is there a way to get the actual image size (width/height) of a cropped image ("Image manipulation" > [Open Editor]) in a fluid template?

All I can come up with is {image.properties} and width and height. But these are the dimensions of the original resource, not the cropped one. And there is of course an attribute crop which holds all the crop info:

{"default":{"cropArea":{"height":0.6431784107946027,"width":0.608,"x":0.037,"y":0.15592203898050974},"selectedRatio":"NaN","focusArea":null}}

But do I really have to find a way to parse this in fluid (if that's even possible)? Isn't there an official way to calculate the actual dimension of a generated image?

My use case is an image gallery component for which I need to explicitly state the image dimensions.

2

There are 2 best solutions below

1
Pravin Vavadiya On

In TYPO3 Fluid, You can crop image like below. See here

<f:image src="{image ogject}" alt="Landscape" width="100c" height="100c" />
1
kimomat On

You could use the VHS Media / SizeViewHelper https://fluidtypo3.org/viewhelpers/vhs/master/Media/SizeViewHelper.html

<f:format.bytes><v:media.size path="{f:uri.image(image: mediaElement, width: 600) -> v:format.trim(characters: '/')}" /></f:format.bytes>