Index: image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/image.module,v
retrieving revision 1.292
diff -u -r1.292 image.module
--- image.module   18 Jan 2009 05:19:10 -0000   1.292
+++ image.module   18 Jan 2009 15:29:08 -0000
@@ -674,7 +674,7 @@
  * Theme a body
  */
 function theme_image_body($node, $size) {
-  return image_display($node, $size);
+return ph_image_navigation($node) . image_display($node, $size);
 }
 
 /**
@@ -1063,3 +1063,43 @@
   );
 }
 
+/**
+ * Function to allow give back/next links on image nodes
+ */
+function ph_image_navigation(&$node) {
+  global $base_url;
+  $previous=0;
+  $next=0;
+  $tmp_prev=-1;
+  $output="<br>";
+  $terms = taxonomy_node_get_terms_by_vocabulary($node, _image_gallery_get_vid());
+  if ($terms) {
+    $term = array_pop($terms);
+    $res = db_query("SELECT n.nid FROM {term_node} t, {node} n WHERE t.tid=$term->tid AND n.nid=t.nid ORDER BY n.created DESC");
+    while ($nidvalue=db_result($res)){
+      if ($previous!=0 && $next==0) {
+        $next=$nidvalue;
+      }
+      if ($nidvalue == intval($node->nid)) {
+        $previous=$tmp_prev;
+      }
+      $tmp_prev=$nidvalue;
+    }
+    $output .= '<div class="links">';
+    if ($previous>0) {
+      $output .= "<a href=\"$base_url/node/$previous\"><< previous photo <<</a> ";
+    }
+    else {
+      $output .= "<< previous photo << ";
+    }
+    $output .= " || ";
+    if ($next>0) { 
+      $output .= "<a href=\"$base_url/node/$next\">>> next photo >></a>"; 
+    }
+    else {
+      $output .= ">> next photo >>";
+    }
+    $output .= '</div><a name=pict></a><br>';
+    return $output;
+  }
+}
\ No newline at end of file