I'm pulling my hair out trying to figure out how to enter a sort order into this script.
<div align="center"><br>
<table align="center" width="100%" id="gallerythumbs">
<tr>
<?
// Gallery Directory
$imgdir = 'gallery/';
//Standard Open Directory Call
$dir = opendir($imgdir) or die("Cannot open directory :" . $imgdir);
//Standard Counter
$cntr = 1;
//How many Colums would you like in the display
$cols = "6";
//Now we set a standard width in pixels
$standard_width = "97";
$imgSub = array("-", "_", ".jpg");
//Now time for the work to get done
while($file = readdir($dir)) // reading the dir
{
if($file <> '.' && $file <> '..')
{
$ext = substr($file, -3);
$caption = str_replace($imgSub,' ',$file);
if(strtolower($ext) == "jpg") {
$size = getimagesize($imgdir ."" . $file);
if($size[0] > $standard_width){ //We will now need to resize the image propely
$calc = $standard_width / $size[0];
$percentage = number_format($calc, 2);
$w = $percentage * $size[0];
$h = $percentage * $size[1];
} else {
$w = $size[0];
$h = $size[1];
}
$large = $imgdir . 'large/'. $file;
$links = "<p><a href='". $imgdir ."". $file ."' rel='lightbox[gallery]' title='". $caption ."' class='galleryenlarge'><img src='images/spacer.gif' width='44' height='10' border='0' alt='Enlarge'></a><a href='". $large ."' class='gallerydownload'><img src='images/spacer.gif' width='53' height='10' border='0' alt='Download'></a></p>";
if($cntr < $cols) {
echo "<td valign='bottom'><a href='". $imgdir ."". $file ."' rel='lightbox[gallery]' title='". $caption ."'><img border='0' src='imgsize.php?w=". $w ."&h=". $h ."&img=". $imgdir ."". $file ."' /></a>". $links ."<td>";
$cntr++;
} else {
echo "<td valign='bottom'><a href='". $imgdir ."". $file ."' rel='lightbox[gallery]' title='". $caption ."'><img border='0' src='imgsize.php?w=". $w ."&h=". $h ."&img=". $imgdir ."". $file ."' /></a>". $links ."<td></tr><tr>";
if($cntr == $cols) {
$cntr = 0;
}
$cntr++;
}
}
}
}
?>
</tr>
</table>
<!--container--></div>
I'm testing it here:
http://www.natenolting.com/lightbox/index.php
I have it loading the images correctly, connected to lightbox for effects, but I'd like to have the script load the images alphabetically, not randomly as it seems.
Anyone willing to take a crack at this?