-
Notifications
You must be signed in to change notification settings - Fork 143
Image Prioritizer Not Saving URL Metrics for AVIF Background Images #1952
Description
Bug Description
When using AVIF images as background images, the validation process in the image prioritizer plugin fails because the server returns an incorrect MIME type. Specifically, a HEAD request to an AVIF image URL (e.g., demo-img-scaled-jpg.avif) is returning application/octet-stream rather than the expected image/avif (or any MIME type starting with image/). This leads the function image_prioritizer_validate_background_image_url to reject the background image, triggering a PHP notice and preventing the image from being included in URL metrics collection.
Many web servers, including default configurations for popular servers like Nginx or Apache, may not be set up to serve AVIF images with the proper MIME type header. As a result, even valid AVIF background images are flagged as invalid.
Below is the error logged:
[21-Mar-2025 17:46:20 UTC] PHP Notice: image_prioritizer_filter_rest_request_before_callbacks(): Error: HEAD request for background image URL did not return an image Content-Type: application/octet-stream. Background image URL: https://core-performance.local/wp-content/uploads/2025/03/demo-img-scaled-jpg.avif. in /Users/aditya/Local Sites/core-performance/app/public/wp-includes/functions.php on line 6114
We do have a site health check specifically for missing AVIF headers so I am not sure if we should handle this case.
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackProjects
Status