I'm not sure where this belongs, but I thought it might be useful to others. It's basically a modification of the image_attach module to allow multiple images to be attached. It looks like work has been going on in this area previously, since the modifications are fairly minor, and mostly revolved around the admin parts of the code.

Why attach multiple images in this way, rather than through img_assist or the like? Purely because you can upload multiple images from the same admin area as the text, and the derivatives are generated properly. It also integrates well with the views output (except in selecting stories with attached images, for example), making nicely formatted teasers _really_ easy to do.

Unique features: ability to position attached images at editor defined positions in the text. Just add the string "[img]" to each point where you would like an image to appear, and it will put the next available image it finds there.

Problems with it:

  1. Uploads don't work very well - you have to preview after each upload.
  2. Views can't base selection on presence/non-presence of image
  3. The ability to position images within the text at any point is rather hacky - not sure what would be the correct way to handle it though
  4. Image positioning can, theoretically, use weights to order images. This is in the database structure on my server, but may well be missing from the attached files. If so, use
    CREATE TABLE `image_attach_multi` (
      `nid` int(11) NOT NULL default '0',
      `iid` int(11) NOT NULL default '0',
      `weight` tinyint(4) default NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

    to create a suitable table - this is down to me not being familiar with Drupal module installation routines, and, due to working on a development box directly, not needing any installation routine yet...

  5. Should work with template overrides, but they don't look very tidy in code thanks to the module name being very long!

Suggestions for improvements welcome, especially in handling the positioning of images within node content - I am sure that there is a better way than overriding the node body for each image...

CommentFileSizeAuthor
image_attach_multi.zip11.83 KBmpettitt

Comments

Hetta’s picture

Status: Active » Needs work

marked http://drupal.org/node/255623 as duplicate.

http://drupal.org/node/81102 includes a few other attempts to solve the problem, for image 4.7 and (http://drupal.org/node/81102#comment-735230) image 5.x-1.x-dev.

http://drupal.org/node/87991 is for image 4.x, so I marked that as duplicate.

mpetitt: a proper patch might be a good idea: http://drupal.org/patch/create .

mpettitt’s picture

Not sure I can do a proper patch - it's effectively a submodule, like the original image_attach. There aren't any changes to the main image module files, and rather than edit the image_attach module files directly, I used them as a basis for the changes.
However, it does appear to correctly create the table it uses on installation to a clean new Drupal install, which was one of the things I wasn't sure about.

maulwuff’s picture

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

nicjasno’s picture

I get this error when trying to use this module:

user warning: Unknown column 'weight' in 'order clause' query: SELECT iid FROM image_attach_multi WHERE nid=9 order by weight asc in /home/nicjasno/webpages/root/finico/modules/image_attach_multi/image_attach_multi.module on line 308.
nicjasno’s picture

Ok, solved... Apparently the module adds only the nid and iid columns by itself. Had to manually add the weight column.

Well, my wish would be for a module to have multible selection boxes with a browse button, where you can just browse all pics you want to attach at once, click submit, and they're attached to the node. Positioning of the images should be done with css.

mpettitt’s picture

Assigned: Unassigned » mpettitt

I'd like to get the browse/attach functionality into it too, but I think there are some other parts that would be needed first, such as allowing uploads without preview. Image positioning can mostly be done with CSS, but you need some way of choosing where in the source the Only local images are allowed. tag will go, if only to allow for layouts like:

<mainstory>
Text
<block>
<image>
Quotes from person in image
</block>
More text
</mainstory>

The block needs to contain the image, and you can't do that with pure CSS positioning, unless you know precisely how many images there are going to be, then you get into per-article CSS which is bad!

I'm hoping to have a chance to do some more work on this as soon as current site goes live, as we'll need the admin side to be a bit smoother then.

coltrane’s picture

Status: Needs work » Closed (duplicate)

Closing this as a duplicate of #81102: Attach Multiple Images with image_attach using Drupal upload mechanism. If you want multiple images in image module there need to be patches that apply against the working development version which at this moment is the 6.x branch. Discussion and code should be consolidated as well.