Display file thumbnails, and originals for lightbox

images php coding issues or problems here.

Moderators: macek, egami, gesf

preciseformwork
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Aug 04, 2010 8:49 am

Display file thumbnails, and originals for lightbox

Postby preciseformwork » Wed Aug 04, 2010 9:13 am

I found a fairly good tutorial http://www.youtube.com/watch?v=fWwKhfQonkQ on creating a dynamic album gallery which displays photos with the aid of lightbox 2 http://www.huddletogether.com/projects/lightbox2/
Only trouble is it links through albums. I want to merely echo out the contents of album with the thumbnails to work with lightbox. Basically echo out the contents of a folder as images. It is just a question of removing a few bits of this code as it works as I want it more or less, just don't want the first bit 'if (!$get_album) has not been selected with a bit more that I can't figure out. Any help appreciated, been on it all week and just can't get it to work. Others in other forums have tried to do it anoher 'better' way that doesn't work at all :help: . Thanks

Code: Select all

<?php
$page = $_SERVER ['PHP_SELF'];

//settings
$column = 5;

//directories
$base = "data";
$thumbs = "thumbs";

//get album
$get_album = $_GET['album'];

if (!$get_album)
{
echo "<p>select an album<p/>";
$handle = opendir($base);
while (($file = readdir($handle)) !==FALSE)
{
if (is_dir($base."/".$file) && $file != "." && $file != ".." && $file != $thumbs)
{
echo "<a href='$page?album=$file'>$file</a></br>";
}
}
}

else
{
if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/")!=NULL || strstr($get_album,"\\")!=NULL)
{
echo "Album does not exist";
}
else
{
echo "<b>$get_album</b></p>";
$handle = opendir($base."/".$get_album);
while (($file = readdir($handle)) !== FALSE)
{
if ($file != "." && $file != ".." && $file != ".DS_Store")
{
echo "<img src='$base/$thumbs/$file'></br>";
}
}
}
}

?>

proxiimiity01
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Aug 07, 2010 2:50 am

Re: Display file thumbnails, and originals for lightbox

Postby proxiimiity01 » Sat Aug 07, 2010 2:54 am

Troubleshooting:

It doesn't work at all. The image opens up in a new window.
This is commonly caused by a conflict between JS scripts. Check your body tag and look for an onload attribute. Example:A quick fix to this problem is to append the initLightbox() to the onload attribute as so:
________________________________________________________________________
New Homes | Cheap Flights


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 2 guests

cron