typo3fluidfluid-images

TYPO3 Fluid: Force image format to be jpg


I have an extension using a Fluid template which looks like this:

<div class="bgimg" style="background-image: url({f:uri.image(src:'uploads/tx_slider/{homeslider1.bgimage}', treatIdAsReference:1, maxWidth:'1600')})"></div>

This works well - the background-image is referenced correctly - and the image is resized if it is too large. However my client started to upload images in PNG format, which resulted in large (>5MB) files in the website output.

I have not found any option to tell the Fluid image helper to convert the PNG image to JPG when processing. What can I do?


Solution

  • as of TYPO3 10.3 there is a new fluid attribute named "fileExtension" for this.

    <f:image fileExtension="jpg" image="{file}" />

    You can read more about this feature here: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.3/Feature-90416-SpecificTargetFileExtensionInImage-relatedViewHelpers.html