Attach Multiple Images with image_attach using Drupal upload mechanism

aaron - August 28, 2006 - 13:32
Project:Image
Version:6.x-1.x-dev
Component:image_attach
Category:feature request
Priority:normal
Assigned:evil_marty
Status:patch (code needs work)
Description

This patch starts the ball rolling for allowing a node author to attach multiple images to a node. It allows multiple images to be submitted, although each image currently requires a preview or submit.

Still todo:
* allow multiple images to be submitted on a single form. (Multiple form elements? Ajax?)
* limit number of images allowed per node type
* allow weighting of order for display of images
* allow user to delete associations (will this also delete the image?)

- Aaron Winborn
Advomatic

AttachmentSize
image_attach_multi.diff.txt6.87 KB

#1

aaron - August 28, 2006 - 13:50

oops; that one had a debugging print_r. here's the proper one.

AttachmentSize
image_attach_multi.diff_0.txt6.85 KB

#2

evil_marty - October 2, 2006 - 23:02
Title:Attach Multiple Images with image_attach» Attach Multiple Images with image_attach using Drupal upload mechanism
Assigned to:Anonymous» evil_marty
Status:patch (code needs review)» by design

I've modified the image_attach module to allow adding multiple images using the Drupal upload mechanism. This allows content creators to upload multiple images within the current page. Images that are not commited to nodes are deleted to ensure no junk or wasted space. This is my first contribution so I would love to get some feedback on this. Thanks =)

AttachmentSize
image_attach.zip5.99 KB

#3

evil_marty - October 2, 2006 - 23:29
Title:Attach Multiple Images with image_attach using Drupal upload mechanism» RE: Attach Multiple Images with image_attach using Drupal upload mechanism

Would be better if I double checked my work before I upload. Sorry guys this is the proper file =)

AttachmentSize
image_attach_0.zip5.89 KB

#4

Jax - October 7, 2006 - 14:20
Title:RE: Attach Multiple Images with image_attach using Drupal upload mechanism» Attach Multiple Images with image_attach using Drupal upload mechanism
Status:by design» active

Did you have to change that much that you have to provide the whole module? Would it be possible to provide a patch, that is easier to review? (http://drupal.org/diffandpatch) Now I have to diff manually to see if the .install has changed and stuff like that.

(btw, if you change the title on your comment you change the title of the issue, I've removed the "RE:")

#5

Jax - October 7, 2006 - 15:07

I replaced the original module by the one provided in your zip and when I try to attach an extra image to the node I get a javascript alter. It is attached to this comment.

AttachmentSize
error_2.png79.38 KB

#6

Jax - October 7, 2006 - 21:26

For those interested in this, I presented another solution here: http://drupal.org/node/87991

@evil_marty: I think I got the error because I didn't have the upload module enabled. I'll try again soon!

#7

dvdweide - October 26, 2006 - 13:00

JAX, your javascript error is in fact a 'not found' page.
You get this because your session didn't cache the newly added cachable path 'upload/image_js'. (see the menu hook)
With a new session it will certainly go better!

Cheers, Danny

#8

dvdweide - October 26, 2006 - 15:03

I have resolved a couple of problems with the 'image_attach' module from evil_marty.

  • uploaded images are now linked to the revision instead of the node. This implies another database modification.
  • made completely compatible with revisions.
    • image nodes are deleted when one deletes a revision, but only if they are not used by other revisions
    • when an image gets removed from the current revision, it won't delete the image node if there are revisions that reference it.
  • as a by-effect of this, already uploaded images don't dissapear anymore when one adds new image.
  • the install now contains a function to upgrade the database.
    • By default existing images will be associated with all revisions of a node.
    • An alternative is available to associate images only with the current revision
    • ATTENTION: i haven't been able to test this, so some feedback would be nice!
  • I supplied patchfiles, as requested by Yax, which apply to the CVS version. Evil-Marty's modifications are included.
    • The module continues to give nasty SQL errors. It seems like some other module goes haywire for some reason.
      When one enters the edit page after having uploaded images, it gives this error for every uploaded image:

      warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /u/mount/photo/appdata/Logomatica/Sites/immovac/site/includes/database.mysql.inc on line 350.

      user warning: Unknown column 'n.name' in 'where clause' query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE n.uid = '1' AND n.name = 'admin' AND n.created = '1161868065' AND n.type = 'image' AND n.images = '' AND n.new_file = '' AND n.title = '' AND n.teaser = '' AND n.status = '' AND n.moderate = '' AND n.promote = '' AND n.sticky = '' AND n.revision = '' AND n.action_on = '' AND n.validated = '' AND n.is_new = '' AND n.nid = '' AND n.vid = '' AND n.changed = '' AND n.priority_override = '' in /u/mount/photo/appdata/Logomatica/Sites/immovac/site/includes/database.mysql.inc on line 121.

      This query is clearly generated, which makes me think of search module involvement....
      That's not part of this module, though.
      Does anyone know where this comes from, and how to solve it?

      Cheers, Danny

    AttachmentSize
    image_attach.patch.zip7.23 KB

    #9

    dvdweide - October 27, 2006 - 18:18
    Version:4.7.x-1.x-dev» 6.x-1.x-dev
    Status:active» patch (code needs work)

    Here is a new patch for the image_attach module.

    • The problem with the SQL error is resolved now.
    • Uploading a new image with the 'submit' button instead of the 'attach' button now works. This ---probably--- means that uploading without javascript works too! (but it has to be tried, of course)
    • The checkboxes above the image no longer mean 'keep' but have become 'delete' checks, just like upload does.

      I just hope Evil-Marty is not gonna shoot me for this...
    • General rework of the code. I moved code from the nodeapi function into their own

    TO DO:
    The module probably doesn't respect access rights yet. It at least needs to check if the user can create images.
    The updater in the .install file has not been tried at all.

    Let me know what you think of it.

    Cheers, Danny

    AttachmentSize
    image_attach.patch_0.zip7.24 KB

    #10

    phildu - November 6, 2006 - 16:07
    Title:Attach Multiple Images with image_attach using Drupal upload mechanism» preserve the "existing image" funtion

    is it possible to preserve the "existing image" funtion ?

    #11

    phildu - November 6, 2006 - 16:25

    sorry i have modify the title of the thread ?

    #12

    dvdweide - November 6, 2006 - 17:14
    Title:preserve the "existing image" funtion » Attach Multiple Images with image_attach using Drupal upload mechanism

    sorry i have modify the title of the thread ?

    You could also change it back of course... anyway, I've done it now. ;)

    I'm not sure about what you are trying to say.
    Do you mean that existing images are discarded when you upload new ones?
    That problem should be resolved if you applied the patch.

    Danny

    #13

    phildu - November 6, 2006 - 19:36

    In fact i want to preserve the new function : add existing image
    and the function : add multiple image

    but the patch erase it

    are they incompatible ??

    #14

    tidalx3 - November 17, 2006 - 16:09

    Same thing here as above

    Adding from existing image(that was upload via other nodes) is gone. That means have to upload new ones everytime even if I already have a existing image already in the image folder
    (that was uploaded via other nodes).

    #15

    dvdweide - November 17, 2006 - 20:31

    It seems like i've overlooked this feature completely.
    I've started out with the code from evil-marty, which also doesn't have this feature in it.

    I'm working on porting this feature from the CVS version to mine. It's pretty well finished now, but i want to do some extra checks.
    I'll upload it on monday.

    Stay tuned!
    Danny

    #16

    dvdweide - November 21, 2006 - 11:39

    This new version includes chances to attach existing images, as implemented in the existing CVS version.

    AttachmentSize
    image_attach_2.patch28.87 KB

    #17

    dvdweide - November 21, 2006 - 11:48

    To add some extra's, here are the translation files for ITALIAN and DUTCH

    Cheers, Danny

    AttachmentSize
    po.zip3.42 KB

    #18

    David Lesieur - January 16, 2007 - 22:16

    I like this approach and the better upload UI. We also get the "detach" feature as a bonus. Unfortunately, the patch doesn't apply anymore.

    #19

    dvdweide - January 18, 2007 - 15:32

    @David Lesieur
    Too much has changed really for a patch, so i'll upload it completely module one of these days.

    Currently i've added 'views' integration (first image only) and a feature to select a 'no images' image, which will be displayed with nodes that don't have any images attached.

    I'm not finished with this yet, and the italian and dutch translations are outdated, so please hold on till' next week!

    Cheers, Danny

    #20

    David Lesieur - January 18, 2007 - 20:14

    Thanks for the update, Danny! BTW, if you implement many features, I think you will have to split your work into separate, smaller patches, if possible, to increase the odds of them ever getting committed. ;-) Also, you might want to have a look at the Views integration that has been committed recently.

    #21

    stanbroughl - February 13, 2007 - 20:45

    what is the status of this? i'd really like to be able to attach more than one image to my cck nodes rather than upload one and do the rest through the file attachment section

    #22

    dvdweide - February 14, 2007 - 13:53

    It's been almost a month now since i promised to upload a new version of this module.
    Sorry about that, but i do have a lot of work on my hands, lately ;)
    But at last, here it is!

    I really wanted to add a complete zipped module, but this doesn't seem to be possible anymore.
    So, i've created a megapatch that will apply agains the 4.7 version.

    Status:
    - It works very well and seems to be stable. I have it installed on live site, and i haven't had any problems with it, yet.
    - Translations are available in Italian and Dutch.
    - Views integration works as well. Only the first image can be shown, and you can choose one of the sizes from the image module.

    @David Lesieur:
    Thanks, i didn't know they added views support in the original. Too bad because i could have copied it, because not suprisingly, it is very similar.
    Personally i think that a patch should never leave a module in an unusable state, so splitting it would be really difficult as one feature implies another or wouldn't make sense without the other.

    Anyway, when i have a little more time at hand i'll look into this.

    Cheers, Danny

    AttachmentSize
    image_attach_6.patch43.97 KB

    #23

    drewish - March 2, 2007 - 00:24

    dvdweide, the translation should not be included in this patch. please submit it separately. and you should be using cvs diff -up to generate the patches.

    #24

    radscientist - March 12, 2007 - 15:00

    I am Wondering if anyone has submitted this functionality, or a patch for the drupal 5 version?

    #25

    dman - March 19, 2007 - 11:22

    OK, what's the status of this? The last patch seems to mention version 1.2.2.3 ... and I've currently checked out 1.9.2.4 and I can't seem to get it to apply. (yeah, and the po files don't help)

    I came looking for the 'detach' button which seems to be missing, but multiples would be nice too, I guess.

    I'd test, but currently cannot, as I suspect this patch is incompatable with DRUPAL-5.

    #26

    kirilius - April 9, 2007 - 15:58

    Hi there!

    I am also interested in this patch very much. What's the current status? Is there a version for Drupal 5.x?

    #27

    dvdweide - April 10, 2007 - 12:09

    For all those that requested status information on this patch, here are the short facts:

    • The patch applies to the 4.7 version only (rev 1.2.2.3 which is the latest in the DRUPAL-4-7 branch)
    • Changes in the patch are quite extensive. Simply merging in the changes from 4.7 -> 5.0 didn't work out.
    • So, there is no 5.0 version available
    • I wish i had time to integrate the multi-image features into the current 5.0 version, but unfortunately i don't :(

    Until i finished my current project i can't switch to 5.0 myself, as this would include the porting of several custom-made modules.
    I'm really sorry about this, but my hands are tied (yeah, i have a boss...)

    Cheers,
    Danny van der Weide

    #28

    oemb29 - April 27, 2007 - 13:14

    Hi everbybody:

    I need the path for 5.0, please any notice send a comment.

    Thanks

    #29

    aaron - April 30, 2007 - 20:07
    Version:6.x-1.x-dev» 5.x-1.x-dev

    changing the version to reflect latest status

    #30

    guardian - May 18, 2007 - 10:28

    can't image_attach be dropped in favor of http://drupal.org/project/upload_image ? at least with upload_image you have multiple image attach and deletion features ?
    so i would suggest to mark it as won't fix

    #31

    chilly_jillie - May 22, 2007 - 11:09

    Is there a 5.0 version already?

    #32

    Boris Mann - June 16, 2007 - 15:57

    Is this something that should be bountied? For it to be a true reverse bounty, we need a developer who can scope the amount of work required and what they would want to get for this.

    #33

    vascopj - August 13, 2007 - 21:36

    Hi

    I have found 3 options for Drupal 5 which all do something similar.
    I have not tried any of them yet.

    http://drupal.org/project/node_images
    http://drupal.org/project/pictures
    http://drupal.org/project/slideshow

    hope they work!
    cheers
    Sean

    #34

    evil_marty - August 14, 2007 - 02:30

    hi guys, thanks for all your interests in the update. I'm sorry I haven't responded in a long time, unfortunately priorities at work were shifted etc. I am now working on migrating my company's sites to 5.0 and was going to update the module to work with it but as gaurdian (post #30) mentioned, I've replaced my use of image_attach with upload_image. This serves as a better implementation and intergrated well with other uploads. In saying that I believe it to be a better solution and unless there is a need for it I wont update the module. Sorry to all those that want this module, if you really do need an update let me know and if I have time can see what I can do. Thanks again guys.

    #35

    -Shaman- - August 25, 2007 - 13:22

    I'm using a multiple image_attach.module by evil_marty (with no patches 'cause I don't know how to patch a files) and I have a lot of errors in my site - in php "invalid argument supplied foreach()" and awful "duplicate entry" errors in my database which are off course very bad thing.

    Do anybody have a solutions for my problems?

    Maybe someone have a working module, already patched?

    #36

    drewish - February 13, 2008 - 07:44
    Version:5.x-1.x-dev» 6.x-1.x-dev

    marked http://drupal.org/node/220986 as a duplicate. i'd like to get this into 6.x-1.x and then backport to 5.x-2.x,

    #37

    hadubard - February 18, 2008 - 15:52
    Version:6.x-1.x-dev» 5.x-1.x-dev
    Category:feature request» task

    Hey folks,

    for a recent project of mine I wrote a version of the image_attach module using methods of the image module and the upload module. It needs xajax to work (for the removing of queued uploads). I just thought I could post it here, maybe it will be useful to somebody.

    I hope you can excuse, that it's not a patch, but I didn't intend to provide it, so at the time of the project I simply started hacking and made a new module. I use it, it works fine as to my installation. If there are problems using it I can not guarantee to be able to help though. Right now I have different priorities.

    But let me know if it works.
    best regards,
    Hadubard

    AttachmentSize
    image_multi_attach.zip38.36 KB

    #38

    joachim - March 2, 2008 - 14:16

    Marked http://drupal.org/node/228560 as duplicate.

    #39

    1.kenthomas - March 9, 2008 - 03:56

    Subscribing.

    #40

    amy_cgi - March 17, 2008 - 02:24

    subscribing

    #41

    carlosegg - March 20, 2008 - 07:12

    Subscribing.

    #42

    coltrane - March 21, 2008 - 18:49
    Version:5.x-1.x-dev» 6.x-1.x-dev
    Category:task» feature request

    i'd like to get this into 6.x-1.x and then backport to 5.x-2.x,

    Updating back to maintainers wishes

    #43

    CoolDreamZ - April 4, 2008 - 07:16

    Also subscribing... this is popular!

    #44

    sotiris - April 18, 2008 - 07:13
    Version:6.x-1.x-dev» 6.x-1.0-alpha1

    Subscribing.

    #45

    Pixeljumper - April 23, 2008 - 16:16

    Hi,

    How would one go about installing xajax? I can't find the module :/

    Best regards,
    Michael :)

    #46

    hamaldus - April 25, 2008 - 14:38

    subscribing

    #47

    Pixeljumper - May 1, 2008 - 14:59

    I found out how to do it...

    Download the module here: http://daryl.learnhouston.com/2005/11/21/xajax-in-drupal/

    #48

    Hetta - May 9, 2008 - 05:33
    Version:6.x-1.0-alpha1» 6.x-1.x-dev

    also see http://drupal.org/node/253503.

    #49

    SeanBannister - May 14, 2008 - 05:39

    +1 this feature, it solves a huge hole in drupla functionality, look forward to the development

    #50

    sylvaingirard - May 15, 2008 - 14:23

    subscribing

    #51

    bneijt - May 22, 2008 - 19:28

    subscribing, I'm waiting for this feature to fix all current problems with image_attach in drupal 6.x ;)

    #52

    mrgoltra - May 25, 2008 - 19:28

    add

    #53

    maulwuff - June 7, 2008 - 07:43

    D5ers: have a look at this patch:
    http://drupal.org/node/267806

     
     

    Drupal is a registered trademark of Dries Buytaert.