Schön Abend !
Damit nicht immer jahreland die gleichen Bilder im Carousel kreisen, hab ich das droplet Random-image bißchen aufgebohrt.
Es übergibt nun einen carousel div mit derzeit 7 zufällige Bildern aus einer Baumstruktur z.B der Foldergallery
für die colorbox vorbereitet.
eine zeit lang wohl im Testgebiet:
http://www.channel-1.de/dbs/cms1/pages/secondlevel/home.php
//: [[Random_carousel_fg?dir=<Verzeichnis>&height=<Pixel>&width=<Pixel>]]
//: leave width free!
//: It is like Random image - it uses foldergalley recursive and is prepared for colorbox.
//: $name is not used, jet.
global $suffixes, $thumbs, $thumbdir, $f_time, $f_latest;
// config
$thumbdir = 'fg-thumbs'; // sub directory for thumbnail images
$suffixes = 'jpg|jpeg|gif|png'; // recognized file suffixes for images
$random = 1;
// end config
$thumbs = isset( $thumb ) ? 1 : 0;
$random = isset( $latest ) ? 0 : 1;
$folder = WB_PATH.MEDIA_DIRECTORY.'/'.$dir;
$names = array();
$dir_handle = @opendir($folder);
$names = recurse_dir( $dir_handle, $folder );
if ( $random ) {
shuffle($names);
$image=$names[0];
$image2=$names[1];
$image3=$names[2];
$image4=$names[3];
$image5=$names[4];
$image6=$names[5];
$image7=$names[6];
}
else {
$image = $f_latest;
}
$name = $image;
if ( preg_match( "#/(\w+)\.\w+$#", $image, $match ) )
{
$name = $match[1];
}
$name = "Zufallsbilder" ;
$a1='<div id="carousel" >'.'<p id="alt-text"></p>' ;
$a2='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a3='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image2.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image2.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a4='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image3.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image3.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a5='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image4.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image4.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a6='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image5.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image5.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a7='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image6.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image6.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$a8='<a href="'.WB_URL.MEDIA_DIRECTORY.''.$image7.'" rel="cslide" title="">'.'<img src="'.WB_URL.MEDIA_DIRECTORY.''.$image7.'" class="cloudcarousel" alt="'.$name.'" width="'.$width.'" height="'.$height.'" /></a>';
$ax='<div id="left-but"></div><div id="right-but"></div></div>';
return $a1.'</br>'.
$a2.'</br>'.
$a3.'</br>'.
$a4.'</br>'.
$a5.'</br>'.
$a6.'</br>'.
$a7.'</br>'.
$a8.'</br>'.
$ax.'</br>' ;
function recurse_dir( $dir_handle, $path )
{
global $suffixes, $thumbs, $thumbdir, $f_time, $f_latest;
$files = array();
//running the while loop
while ( false !== ( $file = readdir($dir_handle) ) )
{
$dir = $path.'/'.$file;
// recurse
if( is_dir($dir) && $file != '.' && $file != '..' )
{
$handle = @opendir($dir);
$files = array_merge(
recurse_dir( $handle, $dir ),
$files
);
} elseif( $file != '.' && $file != '..' && preg_match( "/\.$suffixes$/i", $file ) )
{
if ( $thumbs && ! preg_match( "#/$thumbdir$#i", $path ) )
{
continue;
}
if ( ! $thumbs && preg_match( "#/$thumbdir$#i", $path ) )
{
continue;
}
$timedat = filemtime($path.'/'.$file);
if ( $timedat > $f_time ) {
$f_time = $timedat;
$f_latest = str_ireplace(
WB_PATH.MEDIA_DIRECTORY,
"",
$path.'/'.$file
);
}
$files[] = str_ireplace(
WB_PATH.MEDIA_DIRECTORY,
"",
$path.'/'.$file
);
}
}
//closing the directory
closedir( $dir_handle );
return $files;
}