Problem/Motivation
\Drupal\image\Controller\ImageStyleDownloadController::deliver()
contains the following code:
$path_info = pathinfo(StreamWrapperManager::getTarget($image_uri));
$converted_image_uri = sprintf('%s://%s%s%s', $this->streamWrapperManager->getScheme($derivative_uri), $path_info['dirname'], DIRECTORY_SEPARATOR, $path_info['filename']);
if (!file_exists($converted_image_uri)) {
// ...
}
Though cannot find issues caused by this code in the core, I suppose that scheme should be extracted from the $image_uri
variable instead.
Looks this causes issue in the Remote Stream Wrapper module, for example: image style derivative generation will fail if a style converts image extension (the module itself needs patching from here:#3068898: Image styles setting extension cause access denied).
I also think that there is some inconsistency with using both StreamWrapperManager::...
and $this->streamWrapperManager->...
Initially this code was introduced here: #2630230: Image effect convert fails when image file is in the public files root
Proposed resolution
Use $this->streamWrapperManager->getScheme($image_uri)
as a second argument for the sprintf()
call.