Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292829

Image derivative generation does not work if effect "Convert" in use and file stored in private filesystem

$
0
0

Problem/Motivation

If file is converted to another format, i.e. from jpg to gif, filepath does not match anymore. We already have a piece of code to match converted image uri but it works only for non-private files.

See Drupal\image\Controller\ImageStyleDownloadController::deliver():

    // Don't try to generate file if source is missing.
    if (!file_exists($image_uri)) {
      // If the image style converted the extension, it has been added to the
      // original file, resulting in filenames like image.png.jpeg. So to find
      // the actual source image, we remove the extension and check if that
      // image exists.
      $path_info = pathinfo($image_uri);
      $converted_image_uri = $path_info['dirname'] . DIRECTORY_SEPARATOR . $path_info['filename'];
      if (!file_exists($converted_image_uri)) {
        $this->logger->notice('Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
        return new Response($this->t('Error generating image, missing source file.'), 404);
      }
      else {
        // The converted file does exist, use it as the source.
        $image_uri = $converted_image_uri;
      }
    }

Proposed resolution

  1. Wait for #2702227: Image styles for private files are serving the original instead of derivative
  2. Change code order - first use correct $image_uri ($converted_image_uri), than check if user has access to original file.

Remaining tasks

as above

User interface changes

none

API changes

none

Data model changes

none


Viewing all articles
Browse latest Browse all 292829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>