Closed Mai-Saad closed 3 months ago
When we do the reoptimize process, we try to remove the next gen media files:
Then here:
Then here:
We try to get the next gen. file path but we pass the $this->format
which in this case equals @imagify-avif
OR @imagify-webp
as in here:
Then goes here:
calling the function imagify_path_to_next_gen
with the previously mentioned values but we are expecting values like webp
or avif
Which means that when reoptimize is triggered we are removing the main image file! not the next gen ones which is catastrophic!
What do u think here?
Ummml, what you are saying seems correct. Changing this function :
function imagify_path_to_next_gen( $path, string $format ) {
switch ( $format ) {
case 'webp':
$path = $path . '.webp';
break;
case 'avif':
$path = $path . '.avif';
break;
}
return $path;
}
Would probably fix one issue.
Good find, now that we have the root cause, let's find the best solution to fix it
Changing the format inside switch cases in imagify_path_to_next_gen
would be a solution yes, but will require small changes as this function is called in two places over the code, I'm OK with that solution.
Or we can add another case with the constants WEBP_SUFFIX
and AVIF_SUFFIX
beside webp
and avif
I think the value passed should be fixed in the AbstractProcess
class instead
No warning now and Files updated in upload folder. Note: while AVIF is off, now we arenot creating webP while if AVIF was on we create AVIF with reoptimize (will open separate GH about that if it was still there after merging https://github.com/wp-media/imagify-plugin/pull/809
Note: while AVIF is off, now we arenot creating webP while if AVIF was on we create AVIF with reoptimize
reoptimize_lossless while AVIF on
reoptimize_lossless while AVIF off
reoptimize_smart while AVIF on
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug When clicking reoptimize with lossless or smart compression, image+thumbnails are removed from the upload folder and not regenerated causing a warning
[02-Feb-2024 06:48:10 UTC] PHP Warning: file_get_contents(/var/www/imagify.rocketlabsqa.ovh/htdocs/wp-content/uploads/2024/02/sea2.jpg): Failed to open stream: No such file or directory in /var/www/imagify.rocketlabsqa.ovh/htdocs/wp-includes/functions.php on line 3332
and status in media library is 'This media lacks the required metadata and cannot be optimized.'To Reproduce Steps to reproduce the behavior:
Expected behavior
Screenshots If applicable, add screenshots to help explain your problem.
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