| slideshow.triptracker.net |
|
|
|
Here is the php code that can be used with slideshow.triptracker.net to get it to display photos inside a folder. Save the code below as pix.php on your site. Then upload your pictures to your site, using a separate folder for each "album". Note that using this method will not allow some of the advanced features of the software (captions etc) but if all you want to do is display a bunch of pictures, it works well.
This code just uses album names from the url get variable to set up the slide show.
//----------------------------------snip----------------------------------------------- <?php if (isset($HTTP_GET_VARS)) { $myfolders =$HTTP_GET_VARS['dirs']; $pagetitle = $HTTP_GET_VARS['title']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <?php function directoryToArray($directory, $extension="", $full_path = true) { $array_items = array(); if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory. "/" . $file)) { $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $extension, $full_path)); } else { if(!$extension || (ereg("." . $extension, $file))) { if($full_path) { $array_items[] = $directory . "/" . $file; } else { $array_items[] = $file; } } } } } closedir($handle); } return $array_items; } ?> <title>Album Viewer</title> <style type="text/css"> <!-- a { font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; background-color: #000000; padding: 2px; height: 16px; width: 200px; border: 1px solid #666666; text-decoration: none; font-size: 10px; font-weight: bold; } --> </style> </head> <body> <h4>Album Choices</h4> <script type="text/javascript" src="http://slideshow.triptracker.net/slide.js"> </script> <?php /* ******************************************* Show all photos in a directory ******************************************* This code just uses album names from the url get variable to set up the slide show. It doesn't provide for captioning, but saves the effort of having to load every picture name. It will just show all the .jpg pictures in the album you specify. You can call it from a get form or you can just use a URL that specifies the folder name and what text you want to use as a link. Example: Sets up links to show all pictures in the directory "MyPhotos" and presents the link as "My Photos" and another link to show all pictures in the directory "MyOtherPhotos" and presents the link as "More Photos" http://mysite.com/pix.php?dirs[]=MyPhotos|My+Photos&dirs[]=MyOtherPhotos|More Photos Please note: Directory names cannot contain spaces or other non-alpha-numeric characters. They can include a / to specify subdirectories. (The album name is relative to the location of this php file.) The square brackets in dirs[] are required. Use a "+" in place of spaces in link names and don't use special characters unless you encode them appropriately for a url string. */ $nl = "\n"; for ($foldernum =0; $foldernum< count($myfolders); $foldernum++) { $mydirtemp = explode('|',$myfolders[$foldernum]); $mydir = addslashes($mydirtemp[0]); $myname = addslashes($mydirtemp[1]); $files = directoryToArray($mydir, false); $myobj = "view".$foldernum; $myalbum = ""; $kmd = '<script type="text/javascript">'.$nl; $kmd .= '<!--'.$nl; $kmd .= ' var '. $myobj.' = new PhotoViewer();'.$nl; $kmd .= $myobj.'.setSlideDuration(3000);'.$nl; $kmd .= $myobj.'.disablePanning();'.$nl; $kmd .= $myobj.'.enableAutoPlay();'.$nl; foreach ($files as $value) //only add jpg files! { if (strtoupper (substr($value,strlen($value)-4)) == ".JPG" ) { $myalbum .= $myobj . ".add('" . $value . "');".$nl; } } $kmd .= $myalbum; $kmd .= '//--></script>'.$nl; $kmd .= '<a href="javascript:void('. $myobj .'.show(0))">Slideshow - ' . $myname . '</a><br />'.$nl; echo $kmd; }?> </body> </html> |

