Jump to content

Identifying Image Clicked/Photo Gallery


Alanistic

Recommended Posts

Can anyone point me in the right direction?  I have some php script that will open all the folders in a directory and look for title.jpg.  This will be displayed on the page as a link to page2.  Is there a way on page 2 that I can determine what image was clicked on?

 

I'm trying to setup a kind of image gallery with images on each folder.  The first page displays the title pages and page 2 displays the images themselves.  Rather than have 1 page for each gallery, I'd like to try and do a page that detects what image was used and fill the page with images from the same folder.

 

Any ideas on the best way to do it?

Link to comment
https://forums.phpfreaks.com/topic/151820-identifying-image-clickedphoto-gallery/
Share on other sites

Thanks for the help.  My code is below.  Everything is in a subfolder of the Photos folder.  So for example, Photos/LA.  The code I've written displays all the images in the specified folder under $dir.  What I'm looking for (I think) is a way for $dir to hold the value of the directory selected.

 

 

<?php

 

$dir="./Photos/LA/";

 

$handle = opendir ($dir);

echo '<div align="left">';

while (false !== ($file = readdir($handle))) {

$filepath = $dir.$file;

if($file == "info.txt") {

$array = file($filepath);

echo '<strong><font color="#5A91AB" size="2" face="Arial, Helvetica, sans-serif">'.$array[0].'</font></strong><br>';

echo '<font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">'.$array[1].'</font><p>';

}

if($file != "." && $file != ".." && $file != "TITLE.jpg" && $file != "TITLE.jpg" && $file != "info.txt") {

$filepath = $dir.$file;

#echo $filepath;

echo ' <a href="'.$filepath.'" target="_blank"><img src="'.$filepath.'" width="138" height="104" border="0"></a> ';

}

    }

?>

In the future, please use code tags around your code.

Currently it outputs an image that links to the image when it is clicked on, correct?

You want it to take you to your gallery page and have the gallery page know which folder to grab images from, correct?

It appears you are only grabbing images from one subdirectory using this code, the LA folder. So what is the point?

Thats where I'm at just now.  I have a folder called Photos which has lots of directories.  LA is just one of them.

 

When you go to Photos.php, this will create a series of thumbnails by finding the title.jpg from each folder.  Just now, this code links them all to PhotosLA.php.  What I want it to do is go to Photobucket.php.

 

In Photobucket.php, I want this to know what image was selected.  So if I clicked on the image Photos/LA/title.jpg then this will load all the images from Photos/LA/.  But if I click on the image Photos/NYC/title.jpg then I want it to load all the images from the Photos/NYC/ folder.  This is the bit I'm stuck at.  I can specify a specific directory sure, but I'm looking for a way for this to pick up what directory has been selected on the photos.php and I really don't know how to do that.

 

And sorry about the code tag thing.

<?php

$dir="./Photos/LA/";

$handle = opendir ($dir);
echo '<div align="left">';
   while (false !== ($file = readdir($handle))) {
      $filepath = $dir.$file;
      if($file == "info.txt") {
         $array = file($filepath);
         echo '<strong><font color="#5A91AB" size="2" face="Arial, Helvetica, sans-serif">'.$array[0].'</font></strong><br>';
         echo '<font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">'.$array[1].'</font><p>';
      }
      if($file != "." && $file != ".." && $file != "TITLE.jpg" && $file != "TITLE.jpg" && $file != "info.txt") {
         $filepath = $dir.$file;
         #echo $filepath;
         echo ' <a href="Photobucket.php?dir='.$dir.'" target="_blank"><img src="'.$filepath.'" width="138" height="104" border="0"></a> ';
      }
       }
?>

then in the page Photobucket.php, use $_GET['dir'] to find out what directory you'll need to get images from.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.