wp-media / imagify-plugin

Speed up your website with lighter images without losing quality.
https://imagify.io
73 stars 27 forks source link

The number of missing images from webP or next-gen isnot correct (not considering large image) #813

Closed Mai-Saad closed 8 months ago

Mai-Saad commented 9 months ago

Before submitting an issue please check that you’ve completed the following steps:

Describe the bug We arenot considering large images for missing webp/next gen count

To Reproduce Steps to reproduce the behavior:

  1. on trunk webP is off on clean local site (no images uploaded yet)
  2. upload 2 images (one is small and the other is big)
  3. Enable webP
  4. check the number of images missing webP in settings page => it's 1 instead of 2

Expected behavior number of images missing webP = number of images having generate webp link in media library page

Screenshots If applicable, add screenshots to help explain your problem. mountain

images (47)

Additional context Add any other context about the problem here.

Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming

Miraeld commented 9 months ago

If I may add more details about this,

The reason is because here within WordPress when an image is too big (dimensions) it gets resized and gets added -scaled in the name.

However, in Imagify, we create a backup for the non -scaled version while WordPress use the -scaled in the database and therefore, use it as a main source for this image.

So when the function https://github.com/wp-media/imagify-plugin/blob/2d98bbc79c1b633311334d084b8de0674353e5e8/classes/Bulk/WP.php#L181 tries to get the medias without webp, it returns something like : https://github.com/wp-media/imagify-plugin/blob/2d98bbc79c1b633311334d084b8de0674353e5e8/classes/Bulk/WP.php#L220-L226

And as the image with -scaled in the database does not have a backup file as we did a backup of the non--scaled version. So it lands into the 'error' => 'no_backup' section. Therefore, it is not counted nor optimized.

It may be fixed by https://github.com/wp-media/imagify-plugin/pull/811 tho as within this PR we add the generation of the -scaled version of the backup.

remyperona commented 8 months ago

This should be fixed by https://github.com/wp-media/imagify-plugin/pull/820

Mai-Saad commented 8 months ago

The following scenario fixed on 2.2.0.1: 1- activate imagify 2- upload small and large images => webP created 3- enable avif => generating is 0/2 on clean site

or

1- activate imagify 2- enable avif 3- upload small and large images => avif created 4- dsiable avif => generating 0/2 is displayed in settings