The jsonapi_image_styles module generates incorrect URLs when used with the s3fs

Created on 20 August 2024, 5 months ago

Problem/Motivation

The `jsonapi_image_styles` module generates incorrect URLs when used with the `s3fs` module for storing files on Amazon S3. Instead of pointing to the correct S3 bucket location, the URLs point to the local file system, resulting in broken image links. This issue makes image styles unusable for sites that rely on S3 as the file storage system.

Steps to reproduce

1. Install and configure the `s3fs` module to use Amazon S3 as the default file storage system.
2. Install and enable the `jsonapi_image_styles` module.
3. Upload an image to a content entity that uses image styles.
4. Access the JSON:API endpoint that provides image styles.
5. Observe that the generated URLs for the image styles are incorrect, pointing to the local file system instead of S3.

Proposed resolution

The issue appears to be that `jsonapi_image_styles` generates URLs without accounting for remote file systems like S3. To resolve this, the module should update its URL generation logic to support remote file systems.

Possible resolutions include:
- Modifying the URL generation to use Drupal's `file_url_generator` service, which correctly handles remote file systems.
- Ensuring that image derivatives are generated and stored on the S3 bucket and that the correct URLs are provided.

Remaining tasks

1. Review how `jsonapi_image_styles` currently generates URLs and identify where it assumes local file paths.
2. Update the code to support remote file systems by using appropriate services, such as `file_url_generator`.
3. Test the changes in an environment with `s3fs` configured to confirm the fix.
4. Prepare a patch or pull request for the module maintainers.

User interface changes

No user interface changes are expected since this issue relates to backend URL handling.

API changes

No API changes are anticipated. The changes involve adjusting URL generation and file handling processes.

Data model changes

No changes to the data model are required. The focus is on fixing the logic for generating correct URLs for images stored on remote file systems.

💬 Support request
Status

Active

Version

3.0

Component

Code

Created by

🇵🇹Portugal mashot7 Lisbon

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024