Jump to content

call txt file into lightbox


busnut

Recommended Posts

G'day all.

 

I had a function working perfectly on an existing script where by when the user clicks on the image, the image pops up in the lightbox style and underneath the image it would display information about that photo from a text file. However, as i've now got a script that read multiple directories instead of just one directly, I can't get the script to work anymore.

 

Here is what I had originally to read the file:

 

$text = "gallery/gallery.txt";
$fh=fopen($text, "r"); 

while(!feof($fh)) 
{ 
  $temp = explode("|", $line); 
  $title[$temp[0]] = $temp[1];
  $description[$temp[0]] = $temp[2];
  $photographer[$temp[0]] = $temp[3];
  $line=fgets($fh); 
  unset($temp); 
} 

and then this was inserted into the a href clause:

<a href=$dir/$file rel=\"lightbox\" title=\"$title[$file] <br> $description[$file] \n © $photographer[$file]\">

and the text file was something like this:

filename.jpg|title|description|photographer

And this here is the file that it needs to go in somehow - but unless somebody has a better solution, please advise either way. (also, exif data is no good as multiple people will upload, and some have no idea on what to do with exif data.

function getDirectory( $path = '.', $level = 0 ){ 
    $ignore = array( 'cgi-bin', '.', '..' ); 
    $dh = @opendir( $path ); 
    while( false !== ( $file = readdir( $dh ) ) ){ 
        if( !in_array( $file, $ignore ) ){ 
            if( is_dir( "$path/$file" ) ){ 
                $dir = $path . $file; 
                echo "<p>$file<br>"; 
                $dh1 = @opendir( $dir ); 
                while( false !== ( $image = readdir( $dh1 ) ) ){ 
                    if( !in_array( $image, $ignore ) ){ 
                        if( !is_dir( "$dir/$image" ) ){ 
		echo "<a href=\"$dir/$image\" rel=\"lightbox\"><img src=\"gallery-thumbnail.php?file=$file/$image\" border=2 style='border-color: #981C1E'></a>\n"; 
                        } 
                    } 
                } 
echo "</p>";
                $level++; 
            } 
        } 
    } 
    closedir( $dh ); 
} 
getDirectory('gallery/'); 

Any help is greatly appreciated. Thankyou :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.