Problem/Motivation
The filter Restrict images to this site
checks if an image is local by trying to load image dimensions from the local file, if that fails, the image is marked as remote and removed from the markup:
// Ensure the path refers to an actual image by prefixing the image source
// with the Drupal root and running getimagesize() on it.
$local_image_path = $local_dir . Unicode::substr($src, $base_path_length);
$local_image_path = rawurldecode($local_image_path);
if (@getimagesize($local_image_path)) {
// The image has the right path. Erroneous images are dealt with below.
continue;
}
That code breaks for private://
files, because the image URL looks something like /system/files/inline-images/search.jpg
, but that directory does not exist on disk.
It also breaks when using image style derivatives (particularly an issue when using a module like entity embed). The URL to the image includes a token as a query parameter, and this token is still present when checking for the file on the file system.
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
None. (Well, working private images.)
API changes
None.
Data model changes
None.