Unfortunately, there is no method in the Picasa Web Albums Data API to request images in a specific sort order.
According to the Picasa Web Albums Data API developer's guide:
Note: The entries in a feed are ordered based upon the display order on the web site.
It certainly seems strange that the API (which WP-Juicebox uses to fetch the images) does not return images in the same order as seen on your Google web page but WP-Juicebox just displays the images in the order in which they are returned.
If you want to re-order the images, you'd need to fetch the images first (in the order in which they are returned by Google) and then sort the array of images manually afterwards by whatever criterion you'd like to use. For example, you could order the images by id, published date, updated date, title, summary or filename (all of which are returned as part of the image data and are available to work with).
First of all, you'd need to add functions to WP-Juicebox so that the images could be ordered using each of the available criteria.
You'd then need to instruct WP-Juicebox to use one of these methods after fetching the images.
Open the WP-Juicebox plugin's 'wp-juicebox.php' file in a plain text editor, scroll down to line 1344 and replace:
/**
* Get attachments Picasa
*
* @param string Picasa user id
* @param string Picasa album name
* @return array attachments
*/
function get_attachments_picasa($picasa_user_id, $picasa_album_name) {
$attachments = array();
$name = $this->remove_whitespace($picasa_album_name);
$term = preg_match('/^[0-9]{19}$/', $name) ? 'albumid' : 'album';
$picasa_feed = 'http://picasaweb.google.com/data/feed/api/user/' . $this->remove_whitespace($picasa_user_id) . '/' . $term . '/' . $name . '?kind=photo&imgmax=1600';
$entries = @simplexml_load_file($picasa_feed);
if ($entries) {
foreach ($entries->entry as $entry) {
$attachments[] = $entry;
}
}
return $attachments;
}
... with:
/**
* Get attachments Picasa
*
* @param string Picasa user id
* @param string Picasa album name
* @return array attachments
*/
function get_attachments_picasa($picasa_user_id, $picasa_album_name) {
$attachments = array();
$name = $this->remove_whitespace($picasa_album_name);
$term = preg_match('/^[0-9]{19}$/', $name) ? 'albumid' : 'album';
$picasa_feed = 'http://picasaweb.google.com/data/feed/api/user/' . $this->remove_whitespace($picasa_user_id) . '/' . $term . '/' . $name . '?kind=photo&imgmax=1600';
$entries = @simplexml_load_file($picasa_feed);
if ($entries) {
foreach ($entries->entry as $entry) {
$attachments[] = $entry;
}
}
usort($attachments, array(&$this, 'sort_picasa_xxxxxxxxx'));
return $attachments;
}
/**
* Sort Picasa id
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_id($a, $b) {
$a_id = intval(basename($a->id));
$b_id = intval(basename($b->id));
if ($a_id === $b_id) {
return 0;
}
return $a_id < $b_id ? -1 : 1;
}
/**
* Sort Picasa published
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_published($a, $b) {
$a_published = intval(strtotime($a->published));
$b_published = intval(strtotime($b->published));
if ($a_published === $b_published) {
return 0;
}
return $a_published < $b_published ? -1 : 1;
}
/**
* Sort Picasa updated
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_updated($a, $b) {
$a_updated = intval(strtotime($a->updated));
$b_updated = intval(strtotime($b->updated));
if ($a_updated === $b_updated) {
return 0;
}
return $a_updated < $b_updated ? -1 : 1;
}
/**
* Sort Picasa filename
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_filename($a, $b) {
$a_filename = basename($a->content->attributes()->src);
$b_filename = basename($b->content->attributes()->src);
return strnatcasecmp($a_filename, $b_filename);
}
/**
* Sort Picasa title
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_title($a, $b) {
$a_title = strval($a->title);
$b_title = strval($b->title);
return strnatcasecmp($a_title, $b_title);
}
/**
* Sort Picasa summary
*
* @param string image
* @param string image
* @return integer image
*/
function sort_picasa_summary($a, $b) {
$a_summary = strval($a->summary);
$b_summary = strval($b->summary);
return strnatcasecmp($a_summary, $b_summary);
}
Then, all you'd need to do is replace sort_picasa_xxxxxxxxx in the code above with the name of the function you'd like to use to order your images, e.g. sort_picasa_filename.
I hope this helps.
Please note that the line number above refers to the current version of WP-Juicebox (v1.5.0.1).