Latest (x) image in block

Last modified: June 6, 2006 - 03:26

<?php
 
/*
   * Used with image.module
   * Tested with Drupal 4.6.x
   * To modify change the value of $number to
   * the number of images that you wish to show
   */

 
$number = 1;
 
$thumbs = 0;
  while (
$thumbs<$number) {
   
$images = (image_get_latest($count = 1, 0));
    print
l(image_display($images[0], 'block'),'node/'.$images[0]->nid, array(), null, null, FALSE, TRUE);
   
$thumbs++;
  }
?>

Modified from http://drupal.org/node/53987

Latest x Images (Drupal 5.x)

vinayras - July 13, 2007 - 18:54

<?php
$numImage
= 5;
$images = image_get_latest($numImage);

for(
$i=0;$i<count($images);$i++) {
            echo
l(image_display($images[$i], 'thumbnail'), 'node/'. $images[$i]->nid, array(), NULL, NULL, FALSE, TRUE);
}
?>

This works fine on Drupal 5.x

Vinay Yadav
PHP / Drupal Specialist
http://www.vinayras.com

And for drupal6

jorisx - July 22, 2008 - 23:45

And for drupal6

<?php
$numImage
= 3;
$images = image_get_random($numImage);
//$images = image_get_latest($numImage);

for($i=0;$i<count($images);$i++) { 
    echo
l(image_display($images[$i], 'thumbnail'), 'node/'. $images[$i]->nid, array('html' => TRUE));
}
?>

change numImage for the amount of images
to switch between random and latest: uncomment the line that says "image_get_latest" for the latest images ...

Http://www.reloadmedia.com

 
 

Drupal is a registered trademark of Dries Buytaert.