Well, I guess in your case you will want to use the full PHP approach. Forget all that is WordPress for this gallery… no plugin (that I know of) will allow you to do both. How good are you at PHP?
I would still use glob() to get all the images inside the folders, but I changed my mind and would instead use fopen() and fgets(). fopen() simply opens the text file and fgets() will get one line at a time and place that into a string. Since each of your images|caption are on separate lines, this makes the most sense.
Make two template files… one to hold ALL galleries showing a single thumbnail for each gallery and making it clickable to take you to that particular gallery. Then make another template file that will show all the images inside that particular gallery. BOTH templates will work almost exactly the same… the difference being in the text files read and the path to start from.
Set up your folder structures
Start with a galleries folder inside your images folder (images/galleries). This will be the “root” where all the galleries live. In fact, if you do the code right, all you’ll have to do is create a new folder inside the galleries folder, populate it with images and a text file, and the code will dynamically add that gallery to your site automatically.
Inside this folder should now be all your galleries in separate folders. i.e. “images/galleries/gallery-1”, “images/galleries/gallery-2” and so forth. Name them whatever you like though, it doesn’t matter. It doesn’t even have to follow numeric importance or anything, unless you want to “order” your gallery a certain way.
Inside each of these gallery folders should be a folder called “thumbnails”… i.e. “images/galleries/gallery-1/thumbnails”. This will, of course, hold all the thumbnails for each larger version image. You can skip this step if you plan on using timthumb to generate the thumbnails on the fly.
Inside each of these thumbnails folder, create a “featured.jpg” thumbnail that will mimic your WordPress featured image. This way you’ll always know to call featured.jpg whenever you want to show the featured image for any gallery. We’ll get to this in the next section.
Code the Landing Page (the one that show all the galleries you have)
At this point, code the first template. Use glob() to gather all of the folders inside your root “images/galleries”. Make sure you use if statements to remove unnecessary folders such as ‘.’ and ‘..’. Then loop through each result calling for the featured.jpg image inside the folder’s “thumbnails” folder and add a hyperlink around the image to take the user to your second template, passing the folder name in the URL. This is how the second template will know which folder to show.
If you want to get fancy, you can create a text document in the root that has description information for each gallery… the way to read this file is exactly the same way as we’ll use for the second template.
Code the Second Template (shows the individual gallery’s thumbs and full sized images)
This template does a lot of the same things as before. Use glob() to gather all the images inside the folder name passed in the URL. You already know it’s going to be “images/gallery” so just append “/folder_name_from_URL” to the path for glob(). Again, use if statements to remove unnecessary folders AND files. We don’t want to grab that text file, just the images. Next use something like this:
$handle = fopen("inputfile.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// process the line read.
}
} else {
// error opening the file.
}
Again, you should know the path is “images/galleries/folder_name_from_URL” and you also know the name of the text file… so the fopen should make sense. Every time you iterate through one line of the text file, explode() that line using a pipe (|) because you are already using the pipe to begin with, and then loop through the glob() results to locate the image in question. Use that information to display the thumbnail and link it to it’s larger counterpart.
You can also use things like prettyPhoto or imageZoom to make the whole thing a lot prettier.
I know this looks and sounds like a lot, but believe me it’s really only 20-30 lines of code max. Most of it is repetitive code… Let me know if you need more direction. Do a search on the PHP site for the functions I’ve referenced and you’ll get a lot of examples of how they are used. Some might even be the exact answer you are looking for!