Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

php looping images from directory into jquery slimbox

Avatar of kingsburymedia
kingsburymediaFlag for Canada asked on
JavaScriptWeb DevelopmentPHP
3 Comments1 Solution387 ViewsLast Modified:
I'm trying to use php to grab jpgs from a gallery directory, dynamically resize them and spit them out in a loop to be used with slimbox/lightbox. Everything seems to work great in IE but in Firefox it says there are 14 images (this number can vary) in the slideshow but I'm only testing with 3 images. When I go through the slideshow, it goes through all 3 images then repeats the last image until it hits the end of the phantom iterations. Very strange indeed. Any thoughts on what's wrong?

http://users.xplornet.com/~sabstock/gallery.php
gallery.php

<?php

// GRAB IMAGES FROM DIR, LOOP THEM WITH JQUERY TAGS
$path = "images/gallery/";
$dir_handle = @opendir($path) or die("Unable to open folder");

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

if($file == "thumbnail.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;

$caption = "Gallery Name";

echo '<li><a href="images/gallery/'.$file.'" rel="lightbox-2009" title="'.$caption.'"><img src="images/gallery/thumbnail.php?im='.$file.'" alt="'.$file.'" /></li>';

}
closedir($dir_handle);

?>

/////

thumbnail.php

<?php 
// Useage: thumbnail.php?im=image.jpg
// Optional: thumbnail.php?im=image.jpg&amp;maxsize=100

$im      = $_GET['im'];
$maxsize = $_GET['maxsize'];
            
if ($maxsize == '') {
	$maxsize = 100;
}

// The file
$filename = $im;

// Set a maximum height and width
$width  = $maxsize;
$height = $maxsize;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig)) {
	$width = ($height / $height_orig) * $width_orig;
} else {
	$height = ($width / $width_orig) * $height_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image   = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Output
imagejpeg($image_p);
imagedestroy($image);
imageDestroy($image_p);

?>
ASKER CERTIFIED SOLUTION
Avatar of mr_egyptian
mr_egyptianFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers