Multiple Images on Node

pramudya81 - June 20, 2008 - 09:38

How to do this?

Users may upload multiple images on a single node. But all images must displayed (e.g. in a thumbnail) just like an image module does.

I am using image module but it only allow 1 image per node.

Regards

I think you could do this

cog.rusty - June 20, 2008 - 13:12

I think you could do this with a multivalued imagefield in a CCK type and some theming of the node type's template.

See also:
http://drupal.org/node/144725
http://drupal.org/project/imagefield_gallery

or maybe
http://drupal.org/project/pblog

Upload module

stripped your speech - June 20, 2008 - 13:45

Use the upload module in the Drupal core, don't list files by default (in its settings).

Then its a simple query, a function you can write in template.php, such as (theme name)_get_node_images($nid):

SELECT fid, nid, filename, filepath, filemime FROM {files} WHERE nid = $node->nid AND filemime = 'image/jpeg'

Then, in node.tpl.php, you would put say, after print $content:

<?php print theme('get_node_images', $node->nid) ?>

After querying in template.php, you can write whatever simple loop logic to format the result to return and display. Mix in some javascript, and you're set.

 
 

Drupal is a registered trademark of Dries Buytaert.