POC multiple image types (jpg, webp, avif) #29930
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proof of concept, it's not meant to be merged
How to test:
Install prestashop, with this PR and php 8.1
execute the two following SQL queries, this will simulate that the checkboxes webp and avif have been checked:
INSERT INTO ps_configuration (id_shop_group, id_shop, name, value, date_add, date_upd) VALUES (null, null, 'PS_ADDITIONAL_IMAGE_QUALITY_WEBP', '1', NOW(), NOW());
INSERT INTO ps_configuration (id_shop_group, id_shop, name, value, date_add, date_upd) VALUES (null, null, 'PS_ADDITIONAL_IMAGE_QUALITY_AVIF', '1', NOW(), NOW());
in the BO's image administration page, regenerate all images
In FO, visit a product page, and see the dump, a new
sources
array appears inby_size
's different formats:TODO
@nicosomb, here are some informations that will help you
Do not use this PR as is, it's just a proof of concept, there's code that could be refactored, since I had little time I remained by legacy's logic when there's actually quite some refactoring needed
I just noticed that when checking Delete previous images, it only works for jpg, not for webp (and not for avif), I think it can be fixed in the
AdminImagesController
in the_deleteOldImages
method, there's a regex that doesn't take webp and avif into account.Investigate problems with AVIF:
libavif-dev
package must be installed on the OS, and GD must be compiled with AVIF support, see explanations hereAdding the checkboxes
AdminImagesController
's constructor, see how the form is built using the legacyHelperForm
component, it is documented herePS_CONFIGURATION
table, here are the keys I used:PS_ADDITIONAL_IMAGE_QUALITY_WEBP
andPS_ADDITIONAL_IMAGE_QUALITY_AVIF
, feel free to change this if you want 👍