wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Improve exclusion based on ATF elements with `srcset`

Open remyperona opened this issue 6 months ago • 0 comments

Describe the bug When an ATF element with srcset attribute (can be picture or img) needs to be excluded from lazyload, the formatting of the path to be used as exclusion pattern is not correct:

  • it's only applied to the first element
  • it doesn't handle the size indicator

In addition all of the URLs are part of the same item in the exclusion array, while it is expected to have an URL per item.

An example below:

srcset value

https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10.jpg.avif 1200w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-300x195.jpg.avif 300w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-1024x666.jpg.avif 1024w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-768x500.jpg.avif 768w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-125x81.jpg.avif 125w

After formatting:

wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10.jpg.avif 1200w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-300x195.jpg.avif 300w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-1024x666.jpg.avif 1024w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-768x500.jpg.avif 768w, https://www.example.org/wp-content/uploads/2024/06/mcdonalds-breakfast-burrito-10-125x81.jpg.avif 125w

Expected behavior

  • Formatting should be per each URL in the srcset
  • Each URL in the srcset should be an item in the exclusion array instead of all of them in the same item

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

remyperona avatar Aug 07 '24 19:08 remyperona