What are the benefits of this process over the one used in David Walsh's example - http://davidwalsh.name/generate-photo-gallery/
I think the main advantage is that it's much clearer and the code is more modular and maintainable. If you're doing this just for one gig it doesn't really matter what you use though.
Thanks for the answer.
Substituting this into David Walsh's example seems to work just fine, but it prevents sorting the results using code suggested in this comment: http://davidwalsh.name/generate-photo-gallery#comment-17911
What would need to be done differently for this?
I don't know if it has anything to do with the OS or FS, but for me the files are always sorted (Windows, NTFS).
Now, testing it on Ubuntu, ext4, it indeed doesn't sort automagically. I'll see what I can do.