I realized today that Dummy Image only checks for the existence of a cached image and not for the existence of the original image. This means if an image cache file expires for a file that actually exists within the files folder Dummy Image will continue to serve up a placeholder even though a new cached image could be created from the source.
It turns out, if the image cache file is not found the $path variable returned does not contain 'public://' but rather the whole url. The following code runs a check for the string 'public://'. If it is not found the $path variable is exploded on the word 'public' and 'public://' is prepended to the last array item returned. In this case the presumed original image location is checked instead of the cached location. I have no idea how foolproof this method is but it seems to work fine for my install. It would be great if the image cache array included the original image location but alas.
case DUMMYIMAGE_GENERATE_MISSING:
$path = (strpos($variables['path'], 'public://')) ? $variables['path'] : 'public:/'.array_pop(explode('public', $variables['path']));
if (is_file($path)) {
break;
}
Another option is to run a second check after the first one which might be a little safer, but results in an extra file existence check. Probably six one way half dozen the other.
case DUMMYIMAGE_GENERATE_MISSING:
if (is_file($path) {
break;
}
else {
if (is_file('public:/'.array_pop(explode('public', $variables['path'])))) {
break;
}
}
Comments
Comment #1
naxoc commentedYeah, I see that. Good find :)
I tested the suggestions out and we need a better way. If private:/ is used, it won't work. I'll get back to this one, but please make suggestions if anyone has any!
Comment #2
Anonymous (not verified) commentedYes, that's definitely a problem. I wasn't able to find a way around that either, hence my sort of "hackish" solution up there.
Comment #3
bibo commentedSubscribing.
Anyone else experiencing too many kittens? It seems that this module replaces all my imagecache files with kittens and not just missing ones.
Even if I choose:
"Use dummy images"
* For missing images
Only way to not see cute kittens (at all) is to choose "For no images".
PS: I'm using the latest D7-release.
PPS: Thanks, otherwise this module rocks! I was actually about to code this myself, but as usual.. there's a module for that!
Comment #4
naxoc commentedI think this one is a dupilcate of #1728026: The 'For missing images' option will always fail. Reopen if you still have the problem :)