The code for the image gallery is:
function gallery($filename) { $fin = fopen($filename, "r") or die("Unable to open file"); $lines = explode("\n", fread($fin, filesize($filename))); foreach($lines as $i) { $entries = explode("\t", $i); echo "<figure class=\"galleryImage\">\n"; echo " <img src=\"" . $entries[0] . "\" alt=\"" . $entries[1] . "\"/>\n"; echo " <figcaption>" . $entries[2] . "</figcaption>\n</figure>\n"; } }
Then it is simply a matter of using include or require to include the file, then call the gallery function. The argument $filename the filename (represented as a string) that contains the data for the gallery. This file is a plain text file where each line represents one image in the gallery. On each line, the file name comes first, then the contents of the image's alt attribute, then the description of the image to be used as a caption, all separated by tabs.