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.

Comments

drewish’s picture

i'm not sure about the static $image. shouldn't that data be passed through the node object?

netaustin’s picture

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.

xerexes’s picture

subscribing

coltrane’s picture

Not sure yet about the use of a static but as for testing the patch applies cleanly and images can be attached without errors.

drewish’s picture

marked http://drupal.org/node/220723 as a duplicate

ansorg’s picture

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

xerexes’s picture

Just curious - any reason this hasn't gotten added to a release yet?

NuZeilen’s picture

I just always do something wrong, can someone upload the image_attach.module file that is already patched?

Thx,
Gorik.

jhendow’s picture

Has anyone uploaded a patched file? I'm a windows user and having a miserable time trying to get it to patch correctly.

drewish’s picture

Status: Needs review » Needs work

i'm pretty against the static variable. i think those values should be passed through the forms api.

netaustin’s picture

StatusFileSize
new3.89 KB

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.

0000@drupalchina.org’s picture

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 -_- )

drewish’s picture

Status: Needs work » Needs review
dvdbosch’s picture

How do i install this patch?

mrgoltra’s picture

subscribing

dvdbosch’s picture

Thanks,

And where can i do that? Sorry for the newbisch question.

coltrane’s picture

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.

drewish’s picture

nancydru’s picture

Status: Needs review » Needs work

The patch on #11 did not fix it for me.

CNlQ8o’s picture

subscribing

bneijt’s picture

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.

Hetta’s picture

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.

audiomason’s picture

applied patch. improved but still glitchy.

image attach fails when story is previewed before save.

drewish’s picture

drewish’s picture

marked #265791: image will not attach as a duplicate

nicksergeant’s picture

Subscribing.

vladimir.dolgopolov’s picture

See:
Tests for Image Attach module

The 'static' patch works, the 'no static' one fails the test.

sun’s picture

Status: Needs work » Closed (duplicate)

Patch no longer applies. Also, I think most of the patch's intent is covered in #81102: Attach Multiple Images with image_attach using Drupal upload mechanism already, and the title of this issue is most probably the cause for why this issue never had the attention it deserves. Hence, marking as duplicate.