Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Doing a theme_imagecache() call on a file that doesn't exist returns invalid data.
For any $preset, e.g. "example_preset", it will pass the image $path to imagecache_create_path() and return a string, so if the $path is empty it returns an invalid string:
<img src="/files/imagecache/example/preset/" />
This is because the imagecache_create_path() function does not verify if the $path exists first, it just assumes it is:
function imagecache_create_path($presetname, $path) {
$path = _imagecache_strip_file_directory($path);
return file_create_path() .'/imagecache/'. $presetname .'/'. $path;
}
This should be modified to verify the path exists first, e.g.:
function imagecache_create_path($presetname, $path) {
if (file_exists($path)) {
$path = _imagecache_strip_file_directory($path);
return file_create_path() .'/imagecache/'. $presetname .'/'. $path;
}
else {
return FALSE;
}
}
Then the rest of the module would need to be updated to handle the FALSE return.
Comments
Comment #1
fizk CreditAttribution: fizk commentedMarking as ImageCache 2.x Todo.