Serve Images in Next-Gen Formats
As you automatically crop / resize etc images as they are uploaded - would there be the ability to deliver WebP versions (or similar)?
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): ?>
<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!">
<?php endforeach ?>
Here's a good summary of benefits and use: https://css-tricks.com/using-webp-images/
There's a neat library here that dynamically redirects .png/jpg image urls for supporting browsers and generates .webp images:
We couldn't potentially build something as well.
That certainly looks easier to implement on my side :)
Hello Dave & Tim,
The library link doesn't work anymore. Did you had a copy of the library? or how did you finally get this thing going Tim?