Implemented Google WebP Support

Floren

Well-known member
This would an amazing enhancement for attachments, especially for sites that use many large pictures.
WebP is a new image format that provides lossless and lossy compression for images on the web. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller in size compared to JPEG images at equivalent SSIM index. WebP supports lossless transparency (also known as alpha channel) with just 22% additional bytes. Transparency is also supported with lossy compression and typically provides 3x smaller file sizes compared to PNG when lossy compression is acceptable for the red/green/blue color channels. Webmasters and web developers can use the WebP image format to create smaller and richer images that can help make the web faster.
GD (PHP 5.5) and ImageMagick are supporting WebP. This could be made as option available if PHP 5.5+ is detected. Many of us already use PHP 5.5 anyways.
 
Last edited:
Upvote 115
This suggestion has been implemented. Votes are no longer accepted.
A test I performed, to compare the sizes. JPG files are already compressed (unlike PNG) and WebP managed to squeeze another 8KB out of the picture without losing any quality.

JPG - 170KB

IMG_20140228_233903.jpg


WebP - 162KB

IMG_20140228_233903.webp
 
Would be nice indeed if more web apps natively supported WebP :)

My Xenforo forum is already setup to auto convert jpg/png images to webp for support browsers only via Nginx Pagespeed module and there's huge savings to be had for bandwidth as well as page speed.

Nice savings to be had ~38% according to my pagespeed stats below

Code:
image_file_count_reduction:                                        0
image_rewrites:                                                  633
image_resized_using_rendered_dimensions:                           0
image_norewrites_high_resolution:                                  0
image_rewrites_dropped_intentionally:                            167
image_rewrites_dropped_decode_failure:                             0
image_rewrites_dropped_mime_type_unknown:                          0
image_rewrites_dropped_server_write_fail:                          0
image_rewrites_dropped_nosaving_resize:                            0
image_rewrites_dropped_nosaving_noresize:                        167
image_rewrites_dropped_due_to_load:                                0
image_rewrites_squashing_for_mobile_screen:                        0
image_rewrite_total_bytes_saved:                             4440146
image_rewrite_total_original_bytes:                         11674919
image_rewrite_uses:                                            52672
image_inline:                                                  20451
image_webp_rewrites:                                             378
image_rewrite_latency_total_ms:                               125055
image_ongoing_rewrites:                                            0
image_webp_conversion_gif_timeouts:                                0
image_webp_conversion_png_timeouts:                                0
image_webp_conversion_jpeg_timeouts:                               0
image_webp_alpha_timeouts:                                         0
image_webp_opaque_timeouts:                                        0

pagespeed_webp00.webp
 
Yes it is, but it is still a very good feature. Maybe someone is able to make a plugin for it, like Yireo did for Magento 2:


That module generates webp images and adds them as the primary image to serve and only when the client does not support webp, it will serve the jpg / png alternative. It is a brilliant plugin!
 
The problem also is that the attachments are generated by php, thus a CDN is not able to serve them. Any modern CDN offers the automatic conversion to webp, but that doesn't work with Xenforo at this time, which is a pity. @Brogan are there thoughts about this from Xenforo's perspective?
 
The problem also is that the attachments are generated by php, thus a CDN is not able to serve them. Any modern CDN offers the automatic conversion to webp, but that doesn't work with Xenforo at this time, which is a pity. @Brogan are there thoughts about this from Xenforo's perspective?

Any update on this?
 
If you're using Cloudflare (everyone should be really) there's an option to automatically convert images to webp format.
Unfortunately there still is no XenForo - CloudFlare integration. For example: XenForo makes use of version strings for avatars. Its possible to set Cloudflare to ignore this, but it requires additional functionality to make this work.
 
Is it possible to serve webp when the browser supports it?
For a page full of posts with up to 30 avatars on it, switching to webp would make a difference even if we didn't convert attached images.
 
Is it possible to serve webp when the browser supports it?
For a page full of posts with up to 30 avatars on it, switching to webp would make a difference even if we didn't convert attached images.
That’s what cloudflare and other cdns do. They can serve up webp selectively. It’s also possible to configure your own web server to do same.
 
hmm ...
What I don't quite understand (language barrier?)
Why, or for what, does XF need webp support?
It is quite sufficient if I have all jpg/jpeg/gif etc.
convert files to webp.
XF then delivers them and if the browser understands the webp format, it also displays the images.

Or is it meant that XF recognizes whether a browser understands webp and delivers other graphic formats if the browser does not yet know webp?
 
something like that. as of now, older gen browsers, safari and apple ios browsers are the only platforms where webp is not supported. so you cannot really treat webp as jpg and directly embed it as images. so a backend mechanism is needed that can detect the browser and load the more optimized version of the image. as of now users have to rely on CDNs to get this done.
 
Top Bottom