# Path to image folder $imageFolder = '../../public/assets/images/icons/'; # Show only these file types from the image folder $imageTypes = '{*.svg}'; # Set to true if you prefer sorting images by name # If set to false, images will be sorted by date $sortByImageName = true; # Set to false if you want the oldest images to appear first # This is only used if images are sorted by date (see above) $newestImagesFirst = true; # The rest of the code is technical # Add images to array $images = glob($imageFolder . $imageTypes, GLOB_BRACE); $author_data = json_decode(file_get_contents('list.json'), true); # Sort images if ($sortByImageName) { $sortedImages = $images; natsort($sortedImages); } else { # Sort the images based on its 'last modified' time stamp $sortedImages = array(); $count = count($images); for ($i = 0; $i < $count; $i++) { $sortedImages[date('YmdHis', filemtime($images[$i])) . $i] = $images[$i]; } # Sort images in array if ($newestImagesFirst) { krsort($sortedImages); } else { ksort($sortedImages); } } ?> foreach ($sortedImages as $image): ?> # Get the name of the image, stripped from image folder path and file type extension $filename = basename($image); $name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename); # Begin adding ?>