Hi All,
I have a gallery php page which gathers the photos from a specified directory or images, it is working ok but the major probem im having is that it doesnt always display the files in order.
By this i mean if my images are titled img0, img1, img2 .... img10, img11, img12
they are ordered like so
img0, img1, img10, img11, img12, img2
and not like
img0, img1, img2, img10, img11, img12
does anyone know how to fix this?
here is my code
PHP Code:
<?php
if(isset($is_gallery))//has the user opened a portfolio category
{
$breadcrumbs = "<a href='portfolio.php'>Portfolio</a>"." / "."<a href='portfolio.php?gallery=$is_gallery'>".ucwords($is_gallery)."</a>";
echo $breadcrumbs;
#echo "<h3>".ucwords($is_album)."</h3>";
$dir = "portfolio/".$is_gallery;
$dir2 = $dir."/";
echo "<h3>".$is_gallery." Gallery</h3>";
$count = 0;
//display thumbs
if ($handle = opendir($dir))
{
$x = 1;?>
<div class='wrapper'>
<ul class='gallery clearfix'>
<?php
while (false !== ($entry = readdir($handle)))
{
if($entry != "." && $entry != ".." && strpos($entry,"."))
{
$default_file = $dir."/".$entry;
$target_file = $dir."/".$entry;
$kaboom = explode(".", $target_file); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
$resized_file = $dir."/resized/".$entry;
$wmax = 250;
$hmax = 250;
ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);
// ----------- End Adams Universal Image Resizing Function ----------
// ------ Start Adams Universal Image Thumbnail(Crop) Function ------
$target_file = $resized_file;
$thumbnail = $dir."/thumbs/".$entry;
$wthumb = 150;
$hthumb = 150;
ak_img_thumb($target_file, $thumbnail, $wthumb, $hthumb, $fileExt);
$filename = explode(".",$entry);
$filename = $filename[0];?>
<div class="gallery-image">
<figure class="img-box">
<li>
<a class="lightbox-image" href="<?php echo $default_file?>" rel="prettyPhoto[]" title="<?php echo $desc;?>">
<img src="<?php echo $thumbnail?>" width="150" height="150" alt="<?php echo $alt?>" title="<?php echo $alt?>" /></a>
</li>
</figure>
</div><?php
$count++;
}
}?>
</ul>
</div><?php
}
}
any help would be greatly appreciated
Thanks
Luke