Mikael
Mikael

Reputation: 1319

TYPO3 crop image in fluid

I have croped image in BE. And how to show croped image in the fluid?

I have crope field:

crop => '{"default":{"cropArea":{"height":0.24482758620689654,"width":0.4379310344827
         586,"x":0,"y":0.5586206896551724},"selectedRatio":"16:9","focusArea":null}}' (151 chars)

I tried in fluid:

<f:image image="{file}" crop="{file.crop}" class="main-img"/>

Thank a lot in advance!

Upvotes: 0

Views: 3162

Answers (2)

Paul Beck
Paul Beck

Reputation: 2683

As I know you dont need to tell the f:image ViewHelper anything about the cropping if you only use the default cropvariant. But I had some problems with Mittwald hosted websites - the GraphicsMagick version there was not able to crop somehow (on other Mittwald hosted sites it worked witht the same GM version). So I just switched to ImageMagick on the sites which had problems with cropping in the frontend and then it worked. If there is a problem with GM and cropping, default Content Elements won't even show the cropped variant in backend preview (Text and Media Elements)

Upvotes: 2

Mathias Brodala
Mathias Brodala

Reputation: 6470

The crop attribute is meant for manual cropping of images. What you are looking for is the cropVariant attribute. If you did not add any crop variants yourself, you will most likely at least have the default crop variant, so your snippet should look like this:

<f:image image="{file}" cropVariant="default" class="main-img"/>

For every additional crop variant you add another <f:image/> to render the image for that crop variant.

Upvotes: 0

Related Questions