When uploading an image in img_assist's popup window the form reappears after submission with the image displayed as a thumbnail but with the title and body empty. Those values have to be reentered and the form has to be resubmitted. After that it works like it's supposed to.

Comments

moonray’s picture

Assigned: Unassigned » moonray
Status: Active » Needs review
StatusFileSize
new1.2 KB

Patch attached. This one was actually really simple (even though it took me a while to find it). :-)

mlsamuelson’s picture

I tested the patch. It solves the issue.

Cool! Thanks Moonray.

mlsamuelson

darren oh’s picture

Status: Needs review » Reviewed & tested by the community

That sounds like a review.

zoo33’s picture

Status: Reviewed & tested by the community » Needs work

Good thing we found the broken part. However this patch will defeat the purpose of the switch statement, whatever that purpose is, as the result will be the same regardless of the value of $op. Can it be safely removed? Why is it there?

Another thing: img_assist_upload() is currently using $_POST['op'] which should be replaced by $form_values['op'] according to this (but how do we make the form variables available to this function?).

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new1.19 KB

You are right, of course. I did think about that when I originally spotted the problem, but then I somehow forgot to take out the switch. From what I can tell, all the relevant code is in img_assist_node_add().

Find new patch attached.

zoo33’s picture

StatusFileSize
new1.12 KB

Yeah, I can't understand why that switch was there in the first place. If someone has an idea, please tell!

Anyway, with that removed, $_POST['edit'] is not used anymore, and I also removed $_POST['op'] since that variable isn't used either (not even before this patch). Attaching a new path, should be OK, but please take a look...

manal’s picture

subscribing

moonray’s picture

Thanks for the code cleaning. Goes to show I should never do anything in a rush. :-)

Last patch looks good to be committed.

moonray’s picture

Status: Needs review » Reviewed & tested by the community
zoo33’s picture

Status: Reviewed & tested by the community » Fixed

Committed.
Sorry, I just realized I forgot to give you credit in the cvs message, moonray. I'll double-praise you once we're done with the HTML mode bug. :)

Let's just hope that switch statement didn't do anything important... Better keep this in mind if some weird bugs should turn up...

pj@plainjaingraphics.com’s picture

Title: Uploading images requires extra form submission » Which one of these patches should I use?

And how do I apply a patch?

zoo33’s picture

Title: Which one of these patches should I use? » Uploading images requires extra form submission

Please don't change the issue title unless you have good reason for it, it makes it hard for people to keep track of which issue is which. (Perhaps you didn't realize you changed the title of the whole issue.)

As a rule of thumb, the last patch in an issue is usually the one you should use since it's probably the one that's evolved most. In this case the patch has been committed, which means it's been incorporated into Drupal's code repository (CVS server). When that happens, it will automatically become a part of the latest dev version of the module within a few hours. So all you have to do is download the 5.x-dev version on img_assist's project page.

For information on patching files, there is a page in the handbook about it.

pj@plainjaingraphics.com’s picture

Thanks for telling me about not changing the thread title - I really didn't realize the ramifications of doing it. I'll make sure not to do it in the future.

I'll go download the latest version of this module and hope it works. Thanks for responding to my question.

Anonymous’s picture

Status: Fixed » Closed (fixed)