With reference to http://drupal.org/node/23220...

I tried to change the random image snippet to show the latest posts but I was unsuccessful:

This shows the latest images but with descriptions:

  $thumbs="5";
  $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid 

WHERE n.type = 'image' AND n.status = 1 ORDER BY changed DESC"), $thumbs);
  while ($node = db_fetch_object($result1)) {
    $output .= node_view(node_load(array('nid' => $node->nid)), 1);
  }
print $output;

Another Try just posted up the same last image 10 times,

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

My goal is to have a photoblog style format where the page will be just full of images - hopefully the last 10 or so images.

Thanks,

Marco

Comments

Marco Palmero’s picture

Is it possible to edit the code above to get the "image_get_latest" function to output the last N number of pictures posted?

I know how to get a random 10 images... just by using the code provided in the snippets page.

But if you simply replace the "image_get_random" by "image_get_latest" you get N of the same image...

tgecho’s picture

$thumbs = 1; // change to your number
for($th = '0' ; $th<$thumbs ; $th++) {
$images = (image_get_latest($count = $thumbs, $tid = 0));
print l(image_display($images[$th], 'thumbnail'),'node/'.$images[$th]->nid, array(), null, null, FALSE, TRUE);
}

$count needs to be the total you want, and the $image[0] was only pulling the first item from the array created by image_get_latest().

I shifted stuff around so you just have to change the value of $thumbs at the top to the number of thumbs you want.