I'm creating a very simple photography portfolio site. I would like to
set this up so that my application recognizes and pulls photos from a
given directory (images folder) automatically. This way the entire
site's images can be maintained by simply adding and removing via ftp.
What's the simplest way to go about this? Do I need an xml file? Please
be as specific as possible and thank you! in advance.
(In the end, I plan on having a directory for each of the categories...
portraits, landscape, wedding, etc.)
You can just read all the files in the directory and create image tags
for them dynamically. If you give the filenames good descriptive names
you won't have to hard-code anything, either.
For example, if you have "House Next to Lake.jpg", "Sunset in Santa
Cruz.jpg", etc., you can then do something like:
<% for image_path in Dir.entries(path_to_images) -%>
<%= image_tag image_path %><br>
<% end %>
If you want the images in a specific order you could pre-pend a number
to each image filename, sort the list of images, and then just strip
it off with the regex.