Redirect to original image instead of throwing a 404

Created on 28 May 2025, 10 days ago

Problem/Motivation

When the browser does not support avif images, we currently show a 404 page with the message: Error generating image, request does not accept avif format.. There is no way for the user to fix this, and in some cases (when using varnish or other external caches like cloudflare), the 404 response might even get cached.

Steps to reproduce

  1. Enable the module and configure avif images to be shown
  2. Visit a page with avif images using a browser that does not add image/avif in the Accept header
  3. Observe the broken images

Proposed resolution

Instead of the 404, we should redirect to the original image style.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None

API changes

None

Data model changes

None

Feature request
Status

Active

Version

1.1

Component

Code

Created by

🇳🇱Netherlands seanB Netherlands

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @seanB
  • 🇳🇱Netherlands seanB Netherlands

    Created a MR. Feedback is welcome :)

  • Pipeline finished with Success
    10 days ago
    Total: 320s
    #508918
  • 🇦🇺Australia mstrelan

    Wouldn't this mean that the redirect might be cached in the CDN now? FWIW unsupported browsers shouldn't be requesting the AVIF image, the responsive image formatter should take care of that. Is that not working correctly?

  • 🇳🇱Netherlands seanB Netherlands

    The page cache renders the same HTML for all users. Varying the page cache by the Accept header can lead to a lot of different version of the page cache, making it less efficient. Maybe we could add a very specific custom cache context for specifically the AVIF. I thought about that, but maybe this solution is a bit easier and user friendly. Since it is a 302 temporary redirect this shouldn't be cached.

Production build 0.71.5 2024