Ola!
I modified an existing snippet which alows me to show node pictures at any plave in my site. I modified it to show the latest images uploaded by node images. It is not node dependent but node-image ID dpendent. So if you upload an image to an node from 1 year ago it will still apear in the latest images block, which makes your modification to your node apparent to your readers!

The snippet to put in your template for images from a node is:

    <?php if ($node->node_images) { ?>
	<div id="images">
  	  <!-- Node images -->
	<h2> Image Gallery from this Article</h2>
    <?php
  		   $node = node_load(arg(1));//get node id
  		   $max = variable_get('block_images', 1); //set the number of images to display
      	   $sql = db_query('SELECT * FROM {node_images} WHERE nid=%d AND status=1 ORDER BY weight', $node->nid);
  	 	   while (($data = db_fetch_object($sql)) && ($count < $max)) {
      	   $alt = $data->description;//use description as image alt text
      	   $output = theme('node_images_view', $node, $teaser, $page);
      	   $count++;
      	   print ($output);
  		   }
	 ?>	
	</div>
    <?php } ?>

see http://raoulcollenteur.nl for an example (select a node)

The snippet for the latest images is:

	<div id="images">
  	  <!-- Node images -->
	<h2> Latest Images</h2>
<?php
//use with node_images.module
//displays latest node images
  $max = variable_get('block_images', 3); //set the number of images to display
  $sql = db_query("SELECT * FROM {node_images} WHERE status=1 ORDER BY id DESC");
  while (($data = db_fetch_object($sql)) && ($count < $max)) {
      $pattern = '<a title="'.$data->description.'" rel="lightbox[Frontpage]" href="'.file_create_url($data->filepath).'"> <img src="'.file_create_url($data->thumbpath).'" alt="'.$data->description.'" /> </a>';
      $output = $pattern;
      $count++;
      print ($output);
  }
?>
	</div>

see http://www.kajak-nl.nl02.members.pcextreme.nl/ (my test website)
I used lightbox for the front page but you can just remove the rel="lightbox[Frontpage]" if you don't want to use it.

I think this will be to some use for a lot of people!
Ciao and have fun usaing this code, Raoul

Comments

serkan_isin’s picture

Hi, how can I make that code to act like, the 'latest node images' block, links to the content that image belongs, not to the full-scale picture? Some kind of phototag cloud i want to implement to my site?

stefano73’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Next release of the node_images module will have a block showing the latest node images.