When i noticed images with a new image style where not loaded in, i started to debug the code in "StageFileProxySubscriber.php" There i noticed, when using both hotlink and use_imagecache_root, use_imagecache_root set path is not used, but instead the relative path is still being used.
if ($config->get('use_imagecache_root') && $unconverted_path === $relative_path) {
// Config says: Fetch the original.
$fetch_path = StreamWrapperManager::getTarget($original_path);
}
...
if ($config->get('hotlink')) {
$relative_path = UrlHelper::encodePath($relative_path);
$location = Url::fromUri("$server/$remote_file_dir/$relative_path", [
'query' => $query_parameters,
'absolute' => TRUE,
])->toString();
Proposed solution to remove $fetch_path variable and use $relative_path instead.
Comments
Comment #3
marcellinostroosnijder commentedAdded an MR that removed the variable, let me know if there's any feedback!
Comment #4
marcellinostroosnijder commentedComment #5
smustgrave commentedOnce someone who's hitting this problem tests it I can merge.
Comment #6
smustgrave commentedKnow this module has been a little lax on tests but possible to get a simple kernel test around this?
Comment #7
lisotton commentedI think the solution is not the proper one, as it always deliver the original image, even requesting the URL of an image style.
I think the proper solution is to download the original image and then let Drupal generate the image style locally.
Comment #8
lisotton commented@marcellinostroosnijder I changed your PR to skip the hotlink if the image style is requested, both hotlink and use_imagecache_root is enabled.
Like this we will download the original image and Drupal will be able to generate the image style locally.
Comment #9
lisotton commentedComment #10
smustgrave commentedComment #12
smustgrave commentedAdded a test and will include in alpha release for 4.0.x