@wspollack
Thank you for your input. Any information which might help is appreciated.
@patrick7
With regard to my original suggestion of creating a gallery with JuiceboxBuilder-Pro and then doing the sorting dynamically via PHP when the gallery is displayed (rather than when it is created), here is an example which will display the images in the order in which they were taken (comparing the EXIF 'DateTimeOriginal' values for each image) from earliest to latest.
(1) In your gallery's embedding code, use a configUrl to point to a PHP file named 'sort.php':
<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
new juicebox({
configUrl: "sort.php",
containerId: "juicebox-container",
galleryWidth: "100%",
galleryHeight: "100%",
backgroundColor: "#222222"
});
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->
(2) Create the PHP file named 'sort.php' with the following code:
<?php
header('Content-Type: application/xml');
$xml = simplexml_load_file('config.xml');
$arr = array();
foreach($xml->image as $img) {
$arr[] = $img;
}
usort($arr, function($a, $b) {
$a_exif_data = @exif_read_data($a->attributes()->imageURL);
$b_exif_data = @exif_read_data($b->attributes()->imageURL);
$a_exif_date = !empty($a_exif_data['DateTimeOriginal']) ? strtotime($a_exif_data['DateTimeOriginal']) : '';
$b_exif_date = !empty($b_exif_data['DateTimeOriginal']) ? strtotime($b_exif_data['DateTimeOriginal']) : '';
return $a_exif_date - $b_exif_date;
});
$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;
$settings_tag = $dom_doc->createElement('juiceboxgallery');
foreach ($xml->attributes() as $key=>$value) {
$settings_tag->setAttribute($key, $value);
}
foreach($arr as $img) {
$image_element = $dom_doc->createElement('image');
foreach($img->attributes() as $key=>$value) {
$image_element->setAttribute($key, $value);
}
$title_element = $dom_doc->createElement('title');
$title_text = $dom_doc->createCDATASection($img->title);
$title_element->appendChild($title_text);
$image_element->appendChild($title_element);
$caption_element = $dom_doc->createElement('caption');
$caption_text = $dom_doc->createCDATASection($img->caption);
$caption_element->appendChild($caption_text);
$image_element->appendChild($caption_element);
$settings_tag->appendChild($image_element);
}
$dom_doc->appendChild($settings_tag);
echo $dom_doc->saveXML();
?>
(3) Place the 'sort.php' file in your gallery folder (in the same directory as the gallery's 'config.xml' file).
This solution relies on the images in the gallery's 'images' folder having EXIF info.
Please note that JuiceboxBuilder-Pro strips EXIF info when resizing images so, if you are using JuiceboxBuilder-Pro to create your gallery, you may need to resize your images in an imaging program such as Adobe Photoshop (and ensure that the EXIF info is retained when saving them) before feeding them to JuiceboxBuilder-Pro and then deselect the 'Resize Images' checkbox (on the 'Images' tab) so that JuiceboxBuilder-Pro just copies the images (with EXIF info intact) into the gallery's 'images' folder.
I hope this helps.
Steven, the ability to sort by file creation (capture) date seems like an obvious feature to add.
Thank you for posting your suggestion in the Feature Requests thread. (It keeps all the suggestions together and ensures that they are not overlooked.)