Fetching does not respect use_imagecache_root when using converted webp image styles

Created on 21 November 2023, about 1 year ago
Updated 17 September 2024, 2 months ago

Problem/Motivation

When the "use_imagecache_root" configuration is enabled and the site uses an image style using a conversion to webp, the original image is never downloaded. The "new" \Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber skips over the check for the "use_imagecache_root" for all relative paths added when the subscriber detects "webp".

For reference, \Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber:

      // Is this imagecache? Request the root file and let imagecache resize.
      // We check this first so locally added files have precedence.
      $original_path = $this->manager->styleOriginalPath($relative_path, TRUE);
      if ($original_path && !$is_webp) {
        if (file_exists($original_path)) {
          // Imagecache can generate it without our help.
          return;
        }
        if ($config->get('use_imagecache_root')) {
          // Config says: Fetch the original.
          $fetch_path = StreamWrapperManager::getTarget($original_path);
        }
      }

Steps to reproduce

  1. Enable the "use_imagecache_root" stage_file_proxy configuration.
  2. Create an image style with a conversion to webp.
  3. Visit a page with an image using the test image style.
  4. Actual results: The image style derivative file is downloaded from the origin server.
  5. Expected results: The original image is downloaded from the origin server and then the image style derivative file is created locally using the original image.

Proposed resolution

  • Fix the logic used in \Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber.
  • Improve detection of image styles with a converted file.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States recrit

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