5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 28   (RSS)

Hi Guys.

As you automatically crop / resize etc images as they are uploaded - would there be the ability to deliver WebP versions (or similar)?

Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au

Hi Dave.

I guess I would see it working that every standard image created from the upload (original + thumbs + crops) would have 2 versions - the original format plus the WebP.  Then allow the browser to choose which image format to use.

So, the code generator would output the various different images as usual, ut with the alternates as well.

I would use something like the following in the page code:

<?php foreach ($record['thumbnail'] as $index => $upload): ?>

<picture>
<source srcset="<?php echo htmlencode($upload['urlPath_webp']) ?>" type="image/webp">
<source srcset="<?php echo htmlencode($upload['urlPath_jpg']) ?>" type="image/jpeg">
<img src="<?php echo htmlencode($upload['urlPath_jpg']) ?>" alt="Alt Text!">
</picture>

<?php endforeach ?>

Here's a good summary of benefits and use: https://css-tricks.com/using-webp-images/ 

Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au

Hey Tim, 

There's a neat library here that dynamically redirects .png/jpg image urls for supporting browsers and generates .webp images:
https://github.com/rosell-dk/webp-convert/blob/master/docs/webp-on-demand/webp-on-demand.md

We couldn't potentially build something as well.  

Dave Edis - Senior Developer
interactivetools.com

That certainly looks easier to implement on my side :)

Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au