How do you retrieve a list of the imagefields attached to the node, with file location and node number?

Is there some code to do that?

Comments

yan’s picture

Basically you can use the following simple code snippet:

foreach ($node->field_image_field as $image){
  print $image['<variable>'];
}

where image_field is the name of your imagefield and where <variable> can be one of the following values:

['fid'] --> File ID
['title'] --> Image title
['alt'] --> Image alternate text
['nid'] --> Node ID
['filename'] --> File name
['filepath'] --> Filepath (relative to root)
['filemime'] --> Image mime header
['filesize'] --> File size
['view'] --> HTML code to show image

To get the file's paths and node ID you could use the following, I think:

<ul>
<?php foreach ($field_image as $image): ?>
  <li>Path: <?php print $image['filepath']; ?> // Node: <?php print $image['nid']; ?></li>
<?php endif; ?>
</ul>
dopry’s picture

Status: Active » Closed (fixed)

there is a really cool theme('imagefield', $image) or theme('imagecache_image') function you can use in there somewhere.. up to you to figure out where it goes...