Problem/Motivation

DrimageSubscriber listens on kernel.request at priority 0, after core's RouterListener (32), so a request for a style that does not exist yet 404s in routing first.

  • New sizes fail on the first request. The subscriber only runs inside the 404 sub-request, creates the style there and returns the image inside the 404 response (image/webp, and on some hosts a malformed HTTP/2 response a CDN reports as 520). The second request succeeds.
  • Near sizes never succeed. Within ratio_distortion of an existing style, findImageStyle() reuses that style and never creates the requested name, so the URL 404s every time (e.g. drimage_improved_focal_720_414 while _720_406 exists). One site had 67 image URLs failing this way.

Seen on 1.0.13, Drupal 11.4.7, Varbase 11 with focal_point, single-site and multisite. Related: #3467535: Fix hitting the page with images for the first time results in having images with `page not found` warnings in the syslog.

Steps to reproduce

  1. Install with focal_point and use the Drimage formatter.
  2. Request /sites/default/files/styles/drimage_improved_focal_533_300/public/IMAGE.webp for an existing image and a size with no style yet: 404 first, 200 after.
  3. Request a size one pixel from an existing style: 404 every time.

Proposed resolution

Subscribe at priority 33 in getSubscribedEvents(), before the router. The first request then returns 200 for missing and near sizes alike. Deployed on a live Varbase 11 multisite, all 107 image URLs that had failed now return 200.

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ❌ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support
  • ➖ User Guide Documentation support
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ✅ Update Release Notes
  • ✅ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Assigned: Unassigned » josebc
Status: Active » Needs review
rajab natshah’s picture

Assigned: josebc » Unassigned

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
Status: Needs review » Fixed
Issue tags: +drimage_improved-1.0.14

✅ Released in drimage_improved-1.0.14

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.