wp-media / imagify-plugin

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

1st activation of avif won't run automatically in the background #825

Closed Mai-Saad closed 3 months ago

Mai-Saad commented 3 months ago

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

Describe the bug When we enable AVIF for the 1st time after fresh activation, AVIF won't be automatically generated (reactivate avif will make the creation works automatically)

To Reproduce Steps to reproduce the behavior:

  1. install and activate imagify
  2. upload some images (small, medium, big)
  3. activate avif => (notice that bulk notice isnot displayed)
  4. check media library => generate next-gen link displayed (nothing generated in background)

Expected behavior Automatic creation of avif works even when activating the option for the 1st time

Screenshots Video and sample images screen-capture (84).webm download (33) file_example_JPG_100kB (1) mountain

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

MathieuLamiot commented 3 months ago

We declare maybe_generate_missing_nextgen as a callback to update_option_imagify_settings. However, update_option_xxx hooks seem to only run when updating an option, not creating it. This is explained here and here, and can be seen in WP Core code.

I think we should declare maybe_generate_missing_nextgen as a callback to add_option_imagify_settings as well

MathieuLamiot commented 3 months ago

Also, don't know if it is related: @Tabrisrp I am not sure to understand the meaning of this line in maybe_generate_missing_nextgen

if ( isset( $old_value['convert_to_avif'] ) && isset( $value['convert_to_avif'] ) ) {
    return;
}

Don't we risk to bail out when both are set, but old value is set to 0, and new value to 1?

MathieuLamiot commented 3 months ago

discussing here