Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGSTACK-901 Webp support #201

Open
wants to merge 2 commits into
base: 1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/AppBundle/Resources/config/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ ezpublish:
- { name: strip }

liip_imagine:
# global setting, all filters will generate webp images
default_filter_set_settings:
format: webp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, we're enabling generation of webp by default for all filters, even if the source is jpg or png? If so, that does not sound right?

Copy link
Member Author

@hknezevic hknezevic Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the whole point of the PR. We want to output webp for all web images. Imagick has a possibility of generating webp variations from the source JPG or PNG.
At least that is what Vjeran told me he wants to achieve and test.
We don't want to force editors to upload WEBP originals, but we do want to have WEBP images served on the frontend. On some client media websites, we used Fastly, Cloudinary or Cloudflare to achieve basically the same effect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also an option to configure the liip imagine to generate WEBP only if it is requested in URL (.webp suffix on original image path) and fall back to original type if webp is not requested. This is what Ibexa does by default with their alias paths, however the downside is that you get double the amount of variation images in the storage, which we do not want. Also we do not intend to have fallback formats as all modern browsers have full WEBP support for the past two years.

Copy link
Member

@iherak iherak Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we still have a posibility to define different format or from original source format for some filters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can still define desired output format per filter, like in this example
https://symfony.com/bundles/LiipImagineBundle/current/basic-usage.html#client-side-resolving

Also: https://symfony.com/bundles/LiipImagineBundle/current/configuration.html

  • default_filter_set_settings - specify the default values that will be inherit for any set defined in filter_sets. These values will be overridden if they are specified in the each set. In case of filters and post_processors, the specified values will be merged with the default ones.
  • filter_sets - specify the filter sets that you want to define and use.

filter_sets:
small:
quality: 85
jpeg_quality: 85
# format can also be defined per filter
#format: webp
medium:
quality: 85
jpeg_quality: 85
Expand Down
23 changes: 23 additions & 0 deletions src/AppBundle/ezpublish_legacy/app/settings/image.ini.append.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,27 @@
[MIMETypeSettings]
Quality[]
Quality[]=image/jpeg;90
Quality[]=image/webp;90

# The global conversion rules
# Most will be converted to jpeg except gif and xpms
ConversionRules[]
ConversionRules[]=image/gif;image/png
ConversionRules[]=image/x-xpixmap;image/png
ConversionRules[]=image/webp;image/webp
# force aliases from jpeg originals to be generated as webp
ConversionRules[]=image/jpeg;image/webp
# force aliases from originals in any non-specified format to be generated as webp
#ConversionRules[]=*;image/webp
ConversionRules[]=*;image/jpeg

[OutputSettings]
# A list of MIME types that are allowed as output type
# This determines which formats you want your web page to display
AllowedOutputFormat[]=image/webp

[ImageMagick]
QualityParameters[]=image/webp;-quality %1
MIMETagMap[]=image/webp;WEBP

*/ ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php /* #?ini charset="utf-8"?

[webp]
Types[]=image/webp

*/ ?>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@

[small]
Reference=original
# you can disable global ConversionRules for webp, and specify target mime type for each alias
#MIMEType=image/webp
Filters[]
Filters[]=geometry/scaledownonly=100;100

[medium]
Reference=original
#MIMEType=image/webp
Filters[]
Filters[]=geometry/scaledownonly=200;200

[large]
Reference=original
#MIMEType=image/webp
Filters[]
Filters[]=geometry/scaledownonly=300;300
*/ ?>