Topic: Changing Image Order when using config.php file [SOLVED]

First off, I love Juicebox. So, thanks for making an incredible product.

I'm using a config.php file to create a gallery from images in a folder. I noticed that by default, the images are sorted in ascending order....and I want them sorted in descending order so the gallery shows the newest image first.

I've been racking my brain and searching the interwebs looking for a php script to help me rename files to a new directory in the reverse order but I'm coming up empty handed.

Any ideas on how I can tweak the php file to make this work? Just in case you want to see my demo: http://www.oscarstewart.com/photos.html

Is there a similar gallery setting to flickrSort for non-flicker galleries?

Please help!

Re: Changing Image Order when using config.php file [SOLVED]

If your images are stored in an array, then the easiest way to reverse their order is to use the PHP function array_reverse before you iterate over them to create your <image> entries, e.g:

$images = array_reverse($images);

If this does not help, then please let me see the code of your 'config.php' file so that I can take a look at at and hopefully help further.

Re: Changing Image Order when using config.php file [SOLVED]

Thanks for getting back to me so quickly. Here is the code of my config.php:

<?php
header("Content-type: application/xml");
function GetDirArray($folder)
{
    $handle=opendir($folder);
    while ($file=readdir($handle))
    {
        if ($file!="." && $file!="..")
        {
            $ret[count($ret)]=$file;
        }
    }
    closedir($handle);
    sort($ret);
    return $ret;
}
$gallery=GetDirArray('images');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<juiceboxgallery title="Juicebox Gallery">';
for ($i=0; $i<sizeof($gallery); $i++)
{
    echo '<image imageURL="http://www.oscarstewart.com/images/'.$gallery[$i].'" thumbURL="images/'.$gallery[$i].'" linkURL="" linkTarget="">';
    echo '<title></title>';
    echo '<caption></caption>';
    echo '</image>';
}
echo '</juiceboxgallery>';
?>

Thoughts? And thanks in advance!

Re: Changing Image Order when using config.php file [SOLVED]

Replace:

$gallery=GetDirArray('images');

... with:

$gallery = array_reverse(GetDirArray('images'));

Re: Changing Image Order when using config.php file [SOLVED]

Awesome! It works! Thanks Steven.

Re: Changing Image Order when using config.php file [SOLVED]

You're welcome!