Skip to main content
Support for webp images Started by radu81 · · Read 13009 times 0 Members and 3 Guests are viewing this topic. previous topic - next topic

Support for webp images

https://developers.google.com/speed/webp
I did a test by enabling webp extension in Attachment Settings, the attachment is uploaded, but is displayed as full width inside a post, not as a thumbnail. I attach a screenshot
Untitled.jpg

What do you think about supporting this format in Elkarte? As far as I can see, it was recently added as in wordpress, and I start to see more and more websites using this format for images.
sorry for my bad english

Re: Support for webp images

Reply #1

The main drama with WebP is that it only got added to GD (the graphics library in PHP) relatively recently and I don’t know how up to date hosts are on the subject.

Re: Support for webp images

Reply #2

to avoid this, the webp extension should be disabled from default.
In ACP > Forum > Attachments settings > Allowed attachment extensions > ? :
Screenshot(2).png
we can change:
QuoteSpecify what attachment types are allowed, for example: jpg,png,gif Remember to be careful in what you allow as some file extensions can cause a security risk to your website.
to something like:
QuoteSpecify what attachment types are allowed, for example: jpg,png,gif Remember to be careful in what you allow as some file extensions can cause a security risk to your website. For webp file extension GD library is required....
sorry for my bad english

Re: Support for webp images

Reply #3

I have a foggy memory of looking at this a one point.  I guess the short of it is, yeah it probably should be supported at some point.  I'll add a task on git so we remember.

Re: Support for webp images

Reply #4

Finally looking at this and here is what I'm thinking (and actually have) doing

1) Added a check in the ACP for if you have WebP capability either in GD or Imagick.  This will trigger if you add webp as one of the allowed file types. 
2) With a WebP enabled server, when you upload a WebP image and it will create the thumbnail just like any other image

I'm going to drop the ACP option of "Save thumbnails as PNG" and update the thumbnail functionality as follows:

1) If you have WebP enabled, all thumbnails will be saved as WebP images.  The WebP thumbnail images are smaller in size than JPG or PNG and retain alpha/transparency.  For the thumbs I am only using lossy compression, unlike the old "PNG only thumbs" which by definition were lossless.  The reality is they look just as good but it will saves some space/bandwidth, and its a thumbnail.
2) If you do not have WebP, and the uploaded image is a PNG with some alpha/transparency, then it will create the thumbnail as PNG
3) All others to JPG

Still to do:
1) Avatars
2) How I want integrate WebP options into Image Attachment Resizing (now built into 2.0)

Re: Support for webp images

Reply #5

And a test

Re: Support for webp images

Reply #6


This already looks very promising!  :)
ElkArte version: 1.1.8 / Theme: BeSocial / PHP 8.1

Re: Support for webp images

Reply #7

I don't know why, but entering this thread made the menu icons go blank on an Android mobile.

Re: Support for webp images

Reply #8

Could you flush your cache and see if that helps, there were changes in the css

Re: Support for webp images

Reply #9

Quote from: Spuds – Could you flush your cache and see if that helps, there were changes in the css
That finally worked after the third time. Emptying the Chrome cache doesn't empty the Chrome cache. Apparently you have to threaten it's family. ;D

Re: Support for webp images

Reply #10

I've notice that mobile devices hold the cache at all costs !! :cool: that you got it cleared:smile:

Re: Support for webp images

Reply #11

Let's brake this thing with some tests: :D
sorry for my bad english

Re: Support for webp images

Reply #12

and some inline webp images:

Thumbnail:
1.webp

300px width:
1.webp

Full size:
1.webp

Thumbnail center:
1.webp

Full size right:
1.webp


Quote from: radu81 – Let's brake this thing with some tests: :D
It seems that I wasn't able to do it
Last Edit: February 16, 2022, 02:54:13 am by radu81
sorry for my bad english

Re: Support for webp images

Reply #13

In the end I was able to break something, have a look at the latest image  ;D
sorry for my bad english

Re: Support for webp images

Reply #14

Ah cool, breakage:smile:  I don't think that is specific to webp but an ILA float issue.  Should be an easy :head_bandage:
Last Edit: July 07, 2022, 02:02:42 pm by Spuds