As I understand ImageCache responds to URIs like
http://www.yourdomain.com/default/files/imagecache/set/images/pic.png
where http://www.yourdomain.com
is your domain, files/imagecache
is the imagecache path, set
is the predefined set of image manipulation settings and the rest (here: images/pic.png
) is the actual relative path of the original image.
So, if pic.png doesn't exist, another file (default.png) should be served to ImageCache. An .htaccess solution for non-existant files could be:
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule ^([^.]+)\.[gif|jpg|png]$ /images/default.png [L]
Now ImageCache requests images/pic.png
which does not exist and gets images/default.png
served, processes it and saves it at default/files/imagecache/set/images/pic.png
.
Well, at least this is my theory.
Regards, Paul
-###########-
EDIT regarding first comment:
Ok, I looked into the module. In imagecache.module
, line 386 starts the helper function _imagecache_cache($presetname, $path)
. Within this function is a check for the existance of original file (line 403). Change this block
// Check if the path to the file exists.
if (!is_file($src) && !is_file($src = file_create_path($src))) {
watchdog('imagecache', '404: Unable to find %image ', array('%image' => $src), WATCHDOG_ERROR);
header("HTTP/1.0 404 Not Found");
exit;
};
to
// Check if the path to the file exists.
if (!is_file($src) && !is_file($src = file_create_path($src))) {
watchdog('imagecache', '404: Unable to find %image ', array('%image' => $src), WATCHDOG_ERROR);
/*header("HTTP/1.0 404 Not Found");
exit;*/
$src = 'sites/all/modules/imagecache/sample.png';
};
(Notes: I left the original code lines as comments. You can set $src to any default file you want.)