Multiple Image directories

34 views
Skip to first unread message

Evan

unread,
Jan 4, 2019, 6:22:38 PM1/4/19
to PHPSlideShow by zinkwazi.com
Hello everyone,

I have been through the forum and tried many of the options, but none has seemed to work. I was wondering if anyone has figured out how to get the phpslideshow to read from directories within the main directory and continue the slideshow from there.

For example, I have one main directory called Main_directory with phpslideshow.php within it. There are two subdirectories within Main_directory, one is called "airports" with 5 images in it and another is called "runways" with 10 images in it. 

I need to be able to have the slideshow loop through each of the subdirectories' images once it gets to the end of the previous subdirectory. If anyone could help me, I would GREATLY appreciate it!

Best,

Evan

I Capatosta

unread,
Sep 13, 2019, 2:09:37 PM9/13/19
to PHPSlideShow by zinkwazi.com
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;
      };
Reply all
Reply to author
Forward
0 new messages