Image styles fails with absolute path in $settings['file_public_path']

Created on 23 June 2016, over 8 years ago
Updated 8 July 2024, 6 months ago

Problem/Motivation

My concern is to use the ability provided by $settings['file_public_path'] and $settings['file_public_base_url'] to
provide a separate webserver dedicated to serve static files and user content. For security, this web server has
deliberately no PHP support.

To facilitate the debug of this issue, I created a simple docker-project hosted on Github:
https://github.com/mickaelperrin/drupal-issues/tree/2754273-image_styles...

Steps to reproduce using the docker container:

1. Launch the docker container with docker-compose up -d`
2. Go to http://your.docker.machine.ip:8888
3. Authenticate with drupal / drupal
4. Go to http://your.docker.machine.ip:8888/node/add/article
5. Click on the "Add image" button
6. Select a file

Exepected result: The thumbnail of the selected image is properly displayed

Result: The thumbnail show a missing image (error 404)`

Proposed resolution

The problem seems to be related with the `PathProcessor`of the module `image`. It appends at the beggining of the
public setting path a slash wether the path is absolute or relative.

In case of absolute path, two slashs begin the path and the method to detect if the path is public or private fails, and
so on the url processing.

The attached add a simple test to check if a slash is needed or not.

You can test the issue with the path by launching the docker containers with the command: `docker-compose -f docker-compose.yml -f docker-compose.patched.yml up -d`

Remaining tasks

As it is my first patch and I am new to Drupal, a review is obviously needed.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Image system 

Last updated 1 day ago

Created by

🇫🇷France mickaelperrin

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024