I worked out a method to incorporate this feature into Camera as a native option.
to camera.js:
ADD:
readDir : '', // directory from which to read images ex: '../media/images/large/'
readThumbs : '', // directory from which to read thumbnails ex: '../media/images/thumbs/'
IN the defaults var.
ADD:
/* Load images from directory --------------------------------------------------- */
var thisTemp = this;
function addDiv(file, thumbs)
{
var trueFilePath = file.split('../');
var trueThumbPath = thumbs.split('../');
thisTemp.append('<div data-src="' + trueFilePath[1] + '" data-thumb="' + trueThumbPath[1] + '"></div>');
}
if(opts.readDir.length > 0)
{
$.ajax({
url:'http://YOUR DOMAIN NAME AND LOCATION/getDir.php',
data:{'getDir':opts.readDir},
dataType:'json',
async:false,
success: function(files)
{
if(files)
{
for(var i in files)
{
var ext = files[i].split('.');
if(ext[1]) // not directory, . , ..
{
if(ext[1] == 'jpg' || ext[1] == 'jpeg' || ext[1] == 'png' || ext[1] == 'gif' || ext[1] == 'bmp') addDiv(opts.readDir + files[i], opts.readThumbs + files[i]);
}
}
}
}
});
}
/* ------------------------------------------------------------------------ */
BEFORE
var wrap = $(this).addClass('camera_wrap');
This will work given a few conditions. The originating DIV (i.e. with class="camera_wrap camera_magenta_skin") should be empty, or what is found in the directory will be ADDED to those items. I left this as an option
as apposed to emptying the DIV before refilling it.
The code in your HTML, PHP would now look something like...
<script>
jQuery(function()
{
jQuery('#camera_wrap_1').camera({
thumbnails: true,
readDir: '../media/images/',
readThumbs: '../media/thumbs/'
});
});
</script>
These directories are assumed relative to the JS folder. I did not account for absolute addressing (i.e.
www.example.com/pictures/ ) and assumed the images would not be branched off of the folder where JS resides.
CREATE a new file called getDir.php with the following:
<?php
$dir = $_REQUEST['getDir'];
$files = scandir($dir);
echo json_encode($files);
?>
Put it wherever you want on the server, so long as the AJAX call in the previous step is directed to this file.
I will be including this option in the update I am building hopefully with some more handling for different directory structure options, including absolute addresses, etc but you should be able to work with this
and tweak as needed until that time.
Geoff