Database entry remains after delete image
Juhani - May 5, 2008 - 14:02
| Project: | ImageField |
| Version: | 5.x-2.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Description
I've set up a default image, things displays correctly, as well as when user overrides the default with his own image in a node. But this overriding is permanent that can lead to unwanted (dis)appearances. If user deletes his image, default image doesn't reappear. There's no way to get back default for this field in this specific node.
Everything else works fine with this module. Thank you for the great work.

#1
subscribing
#2
I can't reproduce.
Can you better describe what you expect to happen, and exactly what is happening.. step by step instructions and empirical observations are very helpful.
#3
Well, I hope this use case helps:
1. First I must make "imagefield_default_image" folder to "files" directory, otherwise default image won't upload anywhere.
2. I create a new content type "boo", where I add a new imagefield "foo" and set up a default image for it
3. Then adding necessary user access permissions for "boo".
4. Creating some new content with "boo", not touching "foo" field. Then posting it to the site and a new node "zoo" shows default image and other fields correctly.
5. Editing node "zoo", uploading a new own image "hoo" with image field "foo". Then posting to the site and a new image "hoo" diplays instead of default image and also other fields displays correctly.
6. Editing again node "zoo", imagefield "foo" has my image "hoo" in it, but now checking a checkbox "delete" for it. Then posting to the site and image "hoo" has been removed successfully from the node "zoo".
7. Noticing that field "foo" doesn't display default image either in node "zoo", so field "foo" displays now nothing. I think, it should display default image now again?
8. Well, I go to edit content type "boo" again. I decide to upload a new default image for image field "foo" and saving field settings.
9. I go to see node "zoo". I think there should be a new default image now, but it still displays nothing in field "foo".
10. I even go to truncate Drupal's cache with sql. I decide to edit "zoo", but not touching to field "foo". Posting it to the site again and seeing node "zoo" is still the same. Things would work fine, if I created a new node "doo", but nothing will help for old node "zoo".
Btw, noticed that in db table "content_field_foo" in row of node id of "zoo", still exists references for image "hoo" in columns "field_foo_fid", "field_foo_title" and "field_foo_alt" like there would be image "hoo" in this field. If I reset reset the values back to defaults in this row with sql
UPDATE `content_field_foo` SET `field_foo_fid` = '0', `field_foo_title` = '', `field_foo_alt` = '' WHERE `nid` =[zoo's nid]then I'm getting default image display back to node "zoo". I'm not a coder, but maybe a patch that makes something like this when deleting an image from imagefield could be a solution to this issue.#4
Hi, this issue is linked to #88136: On deleting images, the database entry remains: when deleting an image, the $file is deleted from Drupal folders, but in DB (and for ImageField) the reference still remains. This issue is still im 2.1 version.
I found that way to prevent "default image" to disappear when the image is deleted: it's (IMHO) an hack, and don't tested with multiple images: try my patch ( for the function
function imagefield_file_update($node, &$file, $field)Regards
#5
Hi, this issue is linked to #88136: On deleting images, the database entry remains: when deleting an image, the $file is deleted from Drupal folders, but in DB (and for ImageField) the reference still remains. This issue is still im 2.1 version.
I found that way to prevent "default image" to disappear when the image is deleted: it's (IMHO) an hack, and don't tested with multiple images: try my patch ( for the function
function imagefield_file_update($node, &$file, $field)Regards
#6
I found that the patch provided by thePanz causes all sorts of issues, such as the image not displaying when it should, etc.
A better solution, IMO, that I came up with involves a change to one line of code in imagefield.module.
On line 286, change
return array();toreturn imagefield_default_item();This has the end result of clearing _fid, _title, and _alt fields from the DB table.
P.S. I'm new to Drupal (and PHP), so use this at your own risk :)
#7
Related/several overlapping issues:
http://drupal.org/node/257792#comment-967828
http://drupal.org/node/260585#comment-940301
There are a couple of others also, perhaps merge all into one issue?
#8
I have the same issue.
In addition, the default image will not display in a node view.
I am also using contemplate.
Chris
#9
Changing the title to reflect the real issue.
I'm still seeing the same issue since #88136: On deleting images, the database entry remains, could not find the code, did it get committed? I'm reluctant to reopen an old issue as the patch is no longer relevant. Have always using cosmetic fix since 1.x
To reproduce
- add imagefield to a content type, says story
- add a default image
- create a new story, upload an image, image showing
- edit the story, delete the uploaded image
- the default image is not showing, but a broken link with old uploaded image filename is showing
Field display can be set to anything as far as I can tell.