Are ther plans to introduce a paging system for the image module?
Similar to the pblog module (v 5x.1.3) where when you click on the thumbnail and view the larger image, a 'beginning', 'previous', 'next', 'end' paging system can appear below the image?

Comments

Romka’s picture

To solve this task i'm use next code in node-image.tpl.php:

		$r = db_fetch_object(db_query("SELECT vid FROM {vocabulary} WHERE module = 'image_gallery' LIMIT 0,1"));
		$vid = $r->vid;		
		$r = db_fetch_object(db_query("SELECT n.tid FROM {term_node} n INNER JOIN {term_data} h ON n.tid = h.tid WHERE n.nid = %d AND h.vid = %d", $node->nid, $vid));
		$tid = $r->tid;		
		
		$arr = array();
		$q = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid);
		while($r = db_fetch_object($q)){
			$arr[] = $r->nid;
		}
		for($i = 0; $i <= count($arr) - 1; $i++){
			if($arr[$i] == $node->nid){
				$current = $i;
				break;
			}
		}
		if($current != 0){			
			$r = db_fetch_object(db_query("SELECT f.filepath, n.title, n.nid FROM {files} f INNER JOIN {node} n ON n.nid = f.nid WHERE f.filename = 'thumbnail' AND n.nid = %d LIMIT 0,1", $arr[$current-1]));
			$path = "node/" . $r->nid;
			$path = drupal_get_path_alias($path);
			$prev = "<a href=" . base_path() . $path . "><img src=" . base_path() . $r->filepath . " alt='Prev photo: " . $r->title . "'></a>\n";
		}	else	$prev = "";
		if($current != count($arr) - 1){			
			$r = db_fetch_object(db_query("SELECT f.filepath, n.title, n.nid FROM {files} f INNER JOIN {node} n ON n.nid = f.nid WHERE f.filename = 'thumbnail' AND n.nid = %d LIMIT 0,1", $arr[$current+1]));
			$path = "node/" . $r->nid;
			$path = drupal_get_path_alias($path);
			$next = "<a href=" . base_path() . $path . "><img src=" . base_path() . $r->filepath . " alt='Next photo: " . $r->title . "'></a>\n";
		}	else	$next = "";
		$r = db_fetch_object(db_query("SELECT f.filepath, n.title, n.nid FROM {files} f INNER JOIN {node} n ON n.nid = f.nid WHERE f.filename = 'thumbnail' AND n.nid = %d LIMIT 0,1", $arr[$current]));
		$path = "image/tid/" . $tid;
		$path = drupal_get_path_alias($path);
		$curr = "<a href=" . base_path() . $path . "><img src=" . base_path() . $r->filepath . " alt='Current photo: " . $r->title . ":: ::go to gallery'></a>\n";
		
	}	
	print	"<br><center>" . $prev . $curr . $next . "</center>";

demo here: http://romka.eu/vid-na-oslo-iz-zamka-akerkhus

Hetta’s picture

I've just added all my images to various book pages (using outline). As in, I've created one book page per gallery, and added each image to that, for that gallery.
That gives paging automatically.

Jack_Sparrow’s picture

Thanks Romka,

3 problems I've found...

1. I needed to remove the "}" before print "<br><center>" . $prev . $curr . $next . "</center>";.
IE 7 gives a Parse error: syntax error, unexpected '}' in /path/node-image.tpl.php on line 35

2. All images appear as thumbnails when viewing the larger image, but I'm missing the actual current image which should be the original image.

3. I click on the 1st image in a gallery and IE 7 shows the standard red cross image to show that an image is missing. There shouldn't be a previous link if there is no previous image and likewise there shouldn't be a next image if you reach the last image in a gallery.

I looked at your example and see that yours works fine??? Perhaps it a theme problem... I'm using bluebreeze...

Thank you for your input, I hope we can fix this...

Thank you Hetta,
Unfortunately I'm running a community site and already have many images in various albums and galleries. I don't want to have to redo them as you described, although I'm sure it will work.
I think it'll be quicker to just add some code like Romka submitted...

Thanks again.

Hetta’s picture

Status: Active » Closed (duplicate)

marked as a duplicate of http://drupal.org/node/214714