There are lots of great prewritten scripts to build out relatively custom image slideshows. One of the main issues I’ve run into is that these plugins require a listing of images, and sometimes, it is more convenient to just pull images from a folder directory. Well, even if you don’t know much about PHP, it is incredibly easy to write one! Here, you’ll learn the basic PHP code you’ll need to repeat through all the JPG images within a folder.
<?php $dir = "directory/*.jpg"; foreach(glob($dir) as $image) echo "<img src=\"".$image."\" />"; ?>
That’s it! You just have to update the $dir variable to lead to the folder you want to run through. This script only repeats through JPG images, which you can change by altering the file extension within the $dir variable. Got questions? Ask away!