Here some PHP code that might help
<?php
/* Lets Find all photo files and stote their path and name into an array */
$GalDir = "Pics";
$GalDir = "../C/Pics";
$ScanGalDir = scandir("$GalDir");
$pKT=0;
$ExcludedObjects = array_map ('StrToLower', array ('.','..','index.php', 'Name.txt') );
$ExcludedExtensions = array_map ('StrToLower', array ('html', 'htm', 'php') );
Foreach ($ScanGalDir as $Val)
{
if (!in_array(strtolower($Val),$ExcludedObjects) && !in_array(strtolower($Val),$ExcludedExtensions) && is_dir("$GalDir/$Val") )
{
if ($dh = opendir("$GalDir/$Val"))
{
while (($file = readdir($dh)) !== false)
{
if (!in_array(strtolower($file),$ExcludedObjects) && !in_array(strtolower($file),$ExcludedExtensions) && is_file("$GalDir/$Val/$file") )
{
$Images[] = "\"$GalDir/$Val/$file\"";
$pKT++;
}
}
closedir($dh);
}
}
}
#then to use all the images found do something like
$p=0;
foreach($Images as $Val)
{
$p++;
print " {background-image:url($Val); background-size:contain; background-position:center center; background-repeat:no-repeat;}" .PHP_EOL;
};