Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 12:29:02 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155536 Posts in 21712 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Need help with background image slideshow  (Read 379 times)
hep

Offline Offline

Posts: 1


« on: October 21, 2010, 02:18:18 AM »

I already have some "random background" code that pulls random images from a media folder, but I'd like for it to cycle through all of the images in the folder like a slide show, instead of only loading different background images each time the page loads. Any suggestions? Here's the code I currently have:

$folder=opendir(WB_PATH.MEDIA_DIREC TORY.'/'.$dir.'/.');
$names = array();
while ($file = readdir($folder))  {
   $ext=strtolower(substr($file,-4));
   if ($ext==".jpg"||$ext==".gif"||$ext==".png"){
      $names[count($names)] = $file;
   }
}
closedir($folder);
shuffle($names);
$image=$names[0];
$name=substr($image,0,-4);
$return_img = 'style="background: transparent url(\''.WB_URL.MEDIA_DIREC TORY.'/'.$dir.'/'.$image.'\') no-repeat;"';
return $return_img;
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #1 on: October 21, 2010, 08:31:48 AM »

A webserver and PHP code will never rotate your images automatically.
You will need to add some extra javascript logic in there.

There are many solutions for doing that.
Maybe the captionslider module is something for you.
Logged

Professional WebsiteBaker Solutions
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!