plan2net / webp

Create a WebP copy for images (TYPO3 CMS)
GNU General Public License v3.0
60 stars 34 forks source link

Template Usage #41

Closed lolafrerot closed 3 years ago

lolafrerot commented 3 years ago

Hello, Thanks for this extension, it is nice to have latest web features accessible in TYPO3 !

How am I suppose to use the extension in my templates files ?

So far pictures are printed by :

<f:image src="path/to/image.png" title="" alt="" width="510c" height="320c"/>
-> render 
<img src="path/to/image.png" alt="" width="510" height="320">

But f:image does not render a picture tag with mutliples ressources. This the needed result to use webp images :

<picture>
 <source srcset="path/to/image.webp" type="image/webp">
 <img src="path/to/image.png" alt="MDN">
</picture>

I didn't see any template Example in the readme. This question is for backend stored pictures, and theme ressources pictures too.

Thanks a lot 👍

Lola

wazum commented 3 years ago

@lolafrerot This happens totally transparent, you don't need to handle this in your templates. The webserver decides based on the browser request HTTP headers if the client can handle webp and then sends webp as result instead of the original file (see webserver rewrite rules). hth

lolafrerot commented 3 years ago

Hello, Ok I get it, so if my browser (latest version of Chrome) do not use webp format in source code, this means that my configuration is not correct ?

wazum commented 3 years ago

@lolafrerot you have to check the response headers, not the file extension (file extension will always be e.g. .jpg, only the content and mime type of the file will be webp), see example in screenshot: Screenshot 2020-10-19 at 13 38 51