Fix bugs in hook_nodeapi for image_attach
netaustin - March 12, 2008 - 04:11
| Project: | Image |
| Version: | 6.x-1.x-dev |
| Component: | image_attach |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | patch (code needs work) |
Description
This should fix errors reported here http://drupal.org/node/220723
Bug: image_prepare(), a function which no longer exists in image.module, was being called in hook_nodeapi in image_attach. I inspected the method in the D5 version of image.module and replicated its functionality. I moved logic out of the 'prepare' case and into 'validate' and 'insert'/'update' since the 'prepare' case was never called as expected.
Anyhow, this patch will allow image_attach to be fully functional in Drupal 6.
| Attachment | Size |
|---|---|
| drupal6_node_attach.patch | 2.9 KB |

#1
i'm not sure about the static $image. shouldn't that data be passed through the node object?
#2
I didn't think so... wouldn't the node object be the node which we are trying to attach an image to? $image is a node of its own which we need to initialize in validate, to check for errors, and then save in insert/update.
#3
subscribing
#4
Not sure yet about the use of a static but as for testing the patch applies cleanly and images can be attached without errors.
#5
marked http://drupal.org/node/220723 as a duplicate
#6
applied the patch to a "Image 6.x-1.x-dev (2008-Mar-03)" module in my drupal-6.1 and seems to work, upload from a page edit does work. No sideeffects so far
thanks
Jens
#7
Just curious - any reason this hasn't gotten added to a release yet?
#8
I just always do something wrong, can someone upload the image_attach.module file that is already patched?
Thx,
Gorik.
#9
Has anyone uploaded a patched file? I'm a windows user and having a miserable time trying to get it to patch correctly.
#10
i'm pretty against the static variable. i think those values should be passed through the forms api.
#11
drewish, It seems like there are two ways to get the image node from validate to insert/update intact... 1) static variable, 2) attach the image node to the parent node (I used $node->attached_image)
Anyways, I posted a new patch using the second method; no static $image anymore. Let me know if anything else has to happen to get this working for you.
#12
Sorry but the patch drupal6_node_attach_no_static.patch didn't work for me, mine is 6.x-1.x-dev (2008-4-01)
I tried drupal6_node_attach.patch and this works, both thanks, I got this problem for a very long time, (since the 6.0 released -_- )
#13
marked #243655: Can't upload new image when creating a post. as a duplicate
#14
How do i install this patch?
#15
subscribing
#16
Thanks,
And where can i do that? Sorry for the newbisch question.
#17
dvdbosch, http://drupal.org/patch has an overview of patches with information on applying. If you have other questions drupal.org/support and searching often have the answers.
#18
marked #247457: Image Attach isn't attaching as a patch
#19
The patch on #11 did not fix it for me.
#20
subscribing
#21
It might be better to just drop the current buggy attach and work on a multiple-attach like in this bug: http://drupal.org/node/81102
So anybody who codes on this, consider looking into that other bug.
#22
marked http://drupal.org/node/261900 as duplicate - there, they said that netaustin's patch at the top fixed things, not the patch in #11.
#23
applied patch. improved but still glitchy.
image attach fails when story is previewed before save.
#24
marked #265658: image doesn't attach to story or page node as a duplicate
#25
marked #265791: image will not attach as a duplicate
#26
Subscribing.
#27
See:
Tests for Image Attach module
The 'static' patch works, the 'no static' one fails the test.