S3 redirect does not work if image style path contains a prefix

Created on 23 October 2024, 2 months ago

Problem/Motivation

I inherited a drupal page that uses the drimage β†’ modul to generate image styles. It seems like this modul adds a prefix to the path in the URL.
This is the path of a request to an image style:
/drimage/2720/1530/674/-/s3/files/styles/drimage_1024_/public/2024-09/testttt.png
After reading through the s3fs documentation and issues it looks like the part that is added by this modul, /drimage/2720/1530/674/-, is unexpected and the file path should look like this:
/s3/files/styles/drimage_1024_/public/2024-09/testttt.png

What happens is that the redirect to the S3 Bucket does not work with the /drimage/...-prefix. The image style will be deliviered by drupal. The redirect works if I remove the prefix in the URL.
I've tried multiple solutions with nginx but could not get it to work correctly. Is there a way I can configure s3fs to handle this scenario?

πŸ’¬ Support request
Status

Active

Version

3.6

Component

Code

Created by

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

Comments & Activities

  • Issue created by @wrzd44
  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    /drimage/2720/1530/674/-/ looks like it is a control system of some kind for the drimage module to function correctly especially since the info page says It is meant to take the pain away from configuring and maintaining responsive image styles by simply not needing any configuration..

    If you bypass this I suspect you will not actually have a working deployment with that module, content may be delivered based off the drimage_1024_ image style without customization.

    Nginx could likely be configured to rewrite to s3fs's path, however if at that point if the module is not functioning there would be no need to keep it installed, which would remove the need to rewrite the URL at Nginx.

    This isn't just a prefix, this is the drimage module provide its own independent image style controller to modify the response. S3fs needs to provide a controller controller for the s3fs provided schemes provide the redirect.

    This unfortunately is an area where Drupal Core is not well equipped to handle multiple providers at the moment. Long term the solution is likely ✨ Split ImageStyle into the config entity and a separate event-based image processing service Needs work . Short term you may need to investigate using Core built in responsive image styles. DrImage might be able to fix this in an agnostica manner by checking if the image is on a remote stream wrapper, and redirecting to the target URL.

    For context this is a similar to the following issues that involve competing controllers.
    ✨ Support webp module Closed: won't fix
    ✨ Support webp image style generation via imageoptimize_webp module Closed: won't fix

Production build 0.71.5 2024