Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 11:36:39 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155556 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Random carousel für Foldergallery  (Read 146 times)
gottfried

Offline Offline

Posts: 981


« on: November 25, 2011, 07:37:08 PM »

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


Code:
//: [[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;
}
Logged
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #1 on: November 25, 2011, 07:53:07 PM »

sieht gut aus. leicht ruckelig ab und zu vielleicht.
pause bei mouseover ist gut. vielleicht noch selbst drehen mit mousewheel dazu?
Logged

gottfried

Offline Offline

Posts: 981


« Reply #2 on: November 26, 2011, 10:21:54 AM »

Schön Morgen !
ich hab den Übergang bißchen schneller gemacht, da ruckelt es kaum mehr, bis auf den letzten Tick eben,
wo das Bild exakt plaziert wird.   smiley
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!