Hi,
This is a quirky situation whereby an image is uploaded, say with the name image77.jpg. If that image is then deleted and a new image uploaded with the exact same name but quite a different image, then while the full page version of the image is correct, thumbnails aren't.
This originally occured in version 5.1 so I upgraded but it is still occurring. I have the following in mymodule_nodeapi()
case 'delete':
if($node->type=="image") {
imagecache_preset_flush('thumbnail_preset');
}
I thought this might get rid of any rogue thumbnails, but still I keep getting the thumbnail for the deleted image appearing.
This may well be a problem with the upload module or file.inc but I thought I'd see if anyone else has experienced anything like this.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | imagecache_filefield_hook_issue_362356.patch | 965 bytes | voxpelli |
Comments
Comment #1
apratt commentedRunning into the same problem...
I suspect this is a similar issue #356429: empty IMG tags shown in views where image field is empty just at an earlier stage of diagnosis
I suspect I need to peek into the database to figure out what is happening.
Comment #2
NewZeal commentedI eventually did this in mymodule_nodeapi $op = 'update', which solved the problem:
Comment #3
danny_joris commentedI have the same problem. Deleting old and uploading new original images is no problem, but the images in imagecache/ stay the same. It should be really basic thing to delete or update images in the imagecache folders, right? I haven't tried the above snippet yet, but i feel that i should not be playing around with code snippets for a function that is so standard.
Does anyone have an idea why this happens?
I use the latest version by the way: 6.x-2.0-beta9.
Comment #4
mfbSubscribing
Comment #5
OnlineWD™ commentedI think the problem is ajax, deleting the image and then pressing save is a working process but deleting an image and reuploading the same image or at least image with same file name prevents imagecache image being deleted. This needs to work for making revisions. It's a real headache for webmasters too. I get unknown action when I try to flush cache afterwards and cache is not flushed. I have to go in and manually remove the cache folder before things work properly again. Thanks ..
Comment #6
OnlineWD™ commentedIs a fix for this being considered? It causes havok for my site sometimes and yet when I delete all files in image cache every thing works fine again. Why not simply flush the entire cache every time content is deleted if content contains imagefield?
Comment #7
j0rd commentedI'm having the same issue, which is causing my ubercart install to display the wrong product images.
Here's how you can replicate this bug:
1. Create a node which has a cck imagefield in it. Upload test.jpg and save the node.
2. Visit the node page so that the imagecache thumb is produced.
3. Delete the node.
4. Create another node and upload test.jpg.
5. Visit this new nodes page and you'll notice a stale imagecache thumb.
Here's another way you can replicate this bug:
1. Create a node which has a cck imagefield in it. Upload test.jpg and save the node.
2. Visit the node page so that the imagecache thumb is produced.
3. Remove the image associated with the imagefield and save the node.
4. Edit the same node again, and upload a different picture called test.jpg and save the node.
5. Visit this new nodes page and you'll notice a stale imagecache thumb.
Here's a way you CAN NOT replicate this bug:
1. Create a node which has a cck imagefield in it. Upload test.jpg and save the node.
2. Visit the node page so that the imagecache thumb is produced.
3. Remove the image associated with the imagefield and re-upload another image with the same name.
4. Save the node.
5. Visit this new nodes page and you'll notice that the imagecache is updated. This is because imagefield will re-name the second image uploaded to test_0.jpg thus making it a new name for the image/imagecache.
Solutions for this:
Imagecache will need to delete the cache files it creates when an image is updated or deleted. I would assume this could be done by implementing hook_nodeapi. Otherwise it will have to implement a different storage system based off FID instead of filename.
I consider this a fairly critical bug with imagecache, although most users will never notice it as it would happen rarely. But I'm sure if it was easier to come across, more people would be complaining.
Comment #8
OnlineWD™ commentedI'm not sure but I think after setting imagefield_thumbs folder to 777 and flushing cache my problems have gone. Not 100% sure though, need to test it some more.
Comment #9
j0rd commentedFlushing your cache will solve the problem.
But we can't tell the end users (and perhaps they wont have permissions) to flush their imagecache every time they upload a new image. This isn't practical and there is a bug which causes this problem which should be resolved. It's also a huge burden resource wise as each imagecache thumb will need to be re-created.
Comment #10
premanup commentedI'm using imagecache fairly long time and now described issue happend on my site. There are about a few thousands of imagecached images. So I can't just flush it all.
Comment #11
premanup commentedThis small bash-script has helped me to delete all imagecached files which has no source at the time. I guess it can be used by cron to prevent risk of wrong image show.
Here:
files/i - source directory
files/imagecache/thumb/i - imagecache directory
Comment #12
kanani commentedSubscribing my scenario is second one in #7 except name of image is irrelevant
Comment #13
drewish commentedThere's no way that imagecache can know that the files changed via a hook because Drupal 6 doesn't have a standard notification mechanism for file events. In D7 there's hook_file_update() or hook_file_delete() that can tell us about changes.
If someone wants to roll a patch that compares the timestamp of the source file and the cached image and expires the cached image if it's older than the source file I'd be happy to review it.
Comment #14
voxpelli commented@drewish: hook_file_update() and hook_file_delete() isn't used by Drupal Core in 6.x - but they're actually used by Filefield and Imagefield and it might be a good idea to have imagecache support those hooks - then everyone wanting to tell imagecache that a file has been updated or changed could invoke the hooks and we would have a pretty standard way of talking between files that works very well with Drupal 7.
I'm adding a patch for that.
Comment #15
voxpelli commentedComment #16
drewish commentedvoxpelli, not sure what you're rolling that against because I've already got a imagecache_file_delete() function. Update to HEAD and see if that takes care of it or if we really need to implement update as well.
Comment #17
voxpelli commentedSorry - my mistake - had missed that it has been added in the latest version - should've checked.
Comment #18
j0rd commentedGlad to see some eyes on this. I noticed a new imagecache was released a couple days ago and
"# #447402 by drewish: Not removing derivates for deleted filefield images." was in there.
http://drupal.org/node/447402
Is this the same issue as drewish has mentioned.
Thanks for all the work on this issue.
Comment #19
davepoon commentedI have tried all the suggested solutions(imagecache patches, filefield path module, file replace module, etc)
still can't fix the problem,
we still have to manually delete the files in imagefield_thumbs directory or flush the cache manually,
it is impossible/not user friendly for users or admin users to do that.
It is even more confusing when uploading multiple images,
if admin users reupload the images, or create a new node by uploading the same filename images,
the old thumbnails are displayed,
admin users are frustrated because of the thumbnail preview,
although they are working fine on the node page(the expected imagecache version of the images).
Same filename is needed sometimes,
in my case, I have to allow admin users to upload 8 images (page01.jpg, page02.jpg, etc),
and let a swf/Flash flipbook app to those 8 images with same filename (page01.jpg, page02.jpg, etc).
It will automatically generates an interactive flash flipbook on the page,
but currently, the thumbnail preview is really frustrating to those admin users...
Hope anyone could find a solution to solve the problem, and of course, I am also trying...
Thank you very much.
Comment #20
zoo commentedI encountered the problem described in #1, today.
Deleting an image previously uploaded and then uploading a new image completely different but with the same name of the one deleted, results in the old image still being displayed in the post (thumbnail and full size), as #1 described.
Is there any solution?
No one since january 2010 experienced this issue again? thanks.
zoo
Comment #21
j0rd commentedZoo, have you cleared your browser cache? Do you still have this error.
Also what versions of Drupal, Filefield and Imagecache are you using?
Comment #22
zoo commentedZoo, have you cleared your browser cache? Do you still have this error.
Yes, I have cleared both the browser and Drupal cache, still get the error.
Also what versions of Drupal, Filefield and Imagecache are you using?
It happens with Drupal 6.17 - Filefield 6.x-3.4 - Imagecache 6.x-2.0-beta10
Comment #23
j0rd commentedIt appears the patch I mentioned in #18 was applied to imagecache "beta10". I assume it resolves the issue. I'd recommend adding some debug code into the imagecache.module function imagecache_file_delete hook:
Test if:
1. If the hook is getting called and the file exists.
2. If the file is gone after imagecache_image_flush is called.
If the hook is called and the file is not deleted, we have an issue in imagecache_image_flush I suppose.
You might have to do the work yourself zoo, as I think this is probably working for most people. At the very least, provide the comminity with the steps to duplicate this issue on a fresh install of Drupal 6.17, Filefield 3.4 and Imagecache 2.0-beta10 . You need to do this on a fresh install with only these minimal modules installed.
Cheers,
Jordan
Comment #24
zoo commentedHello j0rd,
thank you, tried and didn't experienced the same problem using a fresh installation of Drupal.
Even though the problem remains in the official site...
zoo
Comment #25
j0rd commentedThen you got something bad floating around. Maybe try disabling modules which are related to this. Un-install them. Download them fresh. Re-enable them. Maybe something bad floating around in the old code or database tables.
Be sure to make backups first :D
Comment #26
zoo commentedHello J0rd,
thank you, yes I know.
Unfortunately right now I've no time to go with the whole process, hoping the problem will heal itself :)
bye
zoo
Comment #27
YK85 commentedsubscribing - im having trouble with old thumbnails showing with the filename is the same
Comment #28
fizk commentedPlease reopen if this is still an issue with 6.x-2.0-rc1.