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

fizk’s picture

Status: Needs work » Postponed
Issue tags: +ImageCache 2.x Todo

Marking as ImageCache 2.x Todo.