thank you @bcworkz @pixellanguage this is helpful info.
Hi,
Have you tried scandir?
It returns an array of filenames within a specified directory. you could do
function get_filenames(){
return scandir(get_template_directory() . '/image');
}
then, loop through that array with foreach to create links.
For subfolders, you could check whether each entry in the returned array has a .jpg, .png, or similar file extension. If not, call scandir on the subdirectory and add the result of that call to the initial array. Rinse and repeat.
Hope this helps!