Page 1 of 1

Displaying thumbnail pages

Posted: Fri Sep 03, 2004 1:51 am
by bradles
I'm using the following script to read my thumbnails from a directory and put them into an array so that I can loop through the array and display the thumbs in a table on a page.

Code: Select all

/***************
**  Settings  **
****************/
$currentdir				= getcwd(); //Current Directory - do not change
$thumbnail_path			= $currentdir . "/thumbnails/";	//folder name for client's thumbnails
$image_path				= $currentdir . "/images/";	//folder name for client's images
$extentions 			= array('jpg','jpeg','JPG', 'JPEG'); //valid file extensions

$thumbs_per_page		= "16"; //maximum amount of thumbnails to display
$thumb_columns			= "4"; //maximum number of columns to display thumbnails

$thumbs = array(); 

//Put the thumbnail images into an array
$dh = opendir($thumbnail_path); 
   while(($file = readdir($dh)) !== false) { 
      // check if it's a file, and it has a valid extension 
      if (is_file($thumbnail_path . $file) && in_array(substr($file, -3), $extentions)) { 
         // add image to array 
         $thumbs[] = $file; 
      } 
   } 
closedir($dh);
I'd like to be able to display them 16 at a time rather than loading 100 odd thumbnails on the one page but i'd like to have a prev/next link setup so that the user can go to the next/prev lot of 16 images.

example: << 1, 2, 3 ... 20 >>
Like you see on message boards.

Is anyone familiar with how to code this sort of thing or can point me in the direction of a tutorial/info.

Brad.

Posted: Fri Sep 03, 2004 2:10 am
by feyd

Posted: Fri Sep 03, 2004 5:48 am
by bradles
Thanks a bundle feyd. You're a champion. :D