getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.58k stars 1.41k forks source link

Feature request: webp by default #3685

Open u07 opened 1 year ago

u07 commented 1 year ago

Hello! Requesting for a really nice but now missing feature. In system.yaml now we have:

images:
  default_image_quality: 85

It would be cool to have something like this:

images:
  default_image_quality: 85
  default_image_format: webp           # (jpg | png | webp | none)

The core now has all the code needed, I mean .format('webp') filter. But it has to be written manually all the time.

mdestafadilah commented 1 year ago

Hello! Requesting for a really nice but now missing feature. In system.yaml now we have:

images:
  default_image_quality: 85

It would be cool to have something like this:

images:
  default_image_quality: 85
  default_image_format: webp           # (jpg | png | webp | none)

The core now has all the code needed, I mean .format('webp') filter. But it has to be written manually all the time.

webp is chrome default image extension for web app. and grav by default has been support it.

https://github.com/getgrav/grav/commit/a4481bfd3315ed6cdf10f9f16aced74ced2d026b

u07 commented 1 year ago

@mdestafadilah, that's right, no problem with support from chrome or grav. So there shouldn't be troubles with implementing this. If it is already implemented, please let me know! Tnx

What I'm talking about is a possible new feature that will convert all the images to webp on the fly as they are served to visitors. That will save a lot of bandwidth and code lines.

mdestafadilah commented 1 year ago

@mdestafadilah, that's right, no problem with support from chrome or grav. So there shouldn't be troubles with implementing this. If it is already implemented, please let me know! Tnx

What I'm talking about is a possible new feature that will convert all the images to webp on the fly as they are served to visitors. That will save a lot of bandwidth and code lines.

aha, i get what you want, try some plugin some one has been created for you.

https://github.com/greenrivers/grav-plugin-webp $ bin/gpm install webp

have a nice day!

u07 commented 1 year ago

Thanks, but that plugin offers manual conversion only. It's not on-the-fly. Just imagine doing it after each new publishing.

rhukster commented 1 year ago

generally speaking converting the image type is more processor intensive than simply resizing and saving in the current format (default). The other issue is that webp can sometimes result in larger files, especially if the files have been optimized with image compression tools.

Probalby the better and more flexible solution is to use something like cloudflare that automaticaly converts to webp (if you enable that option), and also provides added benefit of being a CDN for those images (as well as other static assets).