The random thumbnails weren't working for me -- sometimes I wouldnit get a thumbnail for an album on the gallery page.
When I looked at the code, the query didn't seem to make sense...
A patch follows, although it uses the mysql specific LIMIT clause -- Postgres has something similar, but what is the prefered way of handling this type of thing?
J
--- image/image.module 2003-08-18 12:03:14.000000000 -0700
+++ image2/image.module 2003-08-18 12:08:21.000000000 -0700
@@ -1229,10 +1229,10 @@
$albums[$term_id]->thumb = $last_update->thumb_path;
if (variable_get("image_gallery_thumb", "last") == "random") {
- $nodes = db_fetch_object(db_query("SELECT MIN(nid) as min, MAX(nid) as max FROM {node} WHERE type = 'image'"));
- $id = rand($nodes->min, $nodes->max);
- $random = db_fetch_object(db_query("SELECT i.thumb_path FROM {node} n INNER JOIN {image} i ON n.nid = i.nid INNER JOIN {term_node} t ON n.nid = t.nid WHERE t.tid IN (". implode(",", $terms) .") AND n.type = 'image' AND i.personal = 0 AND n.nid >= ". $id ." LIMIT 1"));
- $albums[$term_id]->thumb = $random->thumb_path;
+ $id = rand (0, ($albums[$term_id]->image_count - 1));
+ $result = db_query ("SELECT i.thumb_path FROM {term_node} tn INNER JOIN {image} i ON tn.nid = i.nid WHERE tn.tid = ". $term_id ." LIMIT " . $id . ", 1" );