PHP image slideshow auto

A solid implementation of an image slideshow gallery. Fully automated, no setup needed.

Usage

For a quick setup:

1. Create a folder for the slideshow images.
2. Drop images for the slideshow in the folder.
3. Grab the code, paste it in a file and call it "index.php"
4. Upload this file to a directory that will be the gallery (http://www.site.com/slideshow/)
5. Change lines 6 and 8 to correspond to your setup.
6. Run it (use URL from step 4)

Comments

Posted on 25.11.2011 22:31 by zedkazi

Hi I am facing problem with the code
am using wamp server

it shows me following code over the page

and this prob arises pleaseinit()) != '') { header('HTTP/1.1 500 Internal Server Error'); echo $err; exit(); } // get image files from directory $ss->get_images(); // set variables, done. list($curr, $caption, $first, $prev, $next, $last) = $ss->run(); /* slideshow class, can be used stand-alone */ class slideshow { private $files_arr = NULL; private $err = NULL; public function __construct(&$err) { $this->files_arr = array(); $this->err = $err; } public function init() { // run actions only if img array session var is empty // check if image directory exists if (!$this->dir_exists()) { return 'Error retrieving images, missing directory'; } return ''; } public function get_images() { // run actions only if img array session var is empty if (isset($_SESSION['imgarr'])) { $this->files_arr = $_SESSION['imgarr']; } else { if ($dh = opendir(IMGDIR)) { while (false !== ($file = readdir($dh))) { if (preg_match('/^.*\.(jpg|jpeg|gif|png)$/i', $file)) { $this->files_arr[] = $file; } } closedir($dh); } $_SESSION['imgarr'] = $this->files_arr; } } public function run() { $curr = 1; $last = count($this->files_arr); if (isset($_GET['img'])) { if (preg_match('/^[0-9]+$/', $_GET['img'])) $curr = (int) $_GET['img']; if ($curr $last) $curr = 1; } if ($curr = $last) { $prev = $last - 1; $next = $last; } else { $prev = $curr - 1; $next = $curr + 1; } // line below sets the caption name... $caption = str_replace('-', ' ', $this->files_arr[$curr - 1]); $caption = str_replace('_', ' ', $caption); $caption = preg_replace('/\.(jpe?g|gif|png)$/i', '', $caption); $caption = ucfirst($caption); return array($this->files_arr[$curr - 1], $caption, 1, $prev, $next, $last); } private function dir_exists() { return file_exists(IMGDIR); } } ?>

followed by an empty picture reference (question mark) and the First | Previous Next | Last anchors
please help
Reply on zedkazi@gmail.com

Posted on 01.10.2011 13:52 by guest

hello ,my name is david noori your scripts is very good but i need demo of your script.why you use not demo?
mydavid66@yahoo.com
i wate for your answer.thanks.by

Posted on 29.08.2011 21:32 by guest

not bad

Posted on 21.07.2011 09:35 by guest

Thanks, very useful!
What to write on line 8, if this php file and images are in the same folder?

Posted on 15.07.2011 09:16 by guest

good of u thanks for sharing

Posted on 09.06.2011 12:37 by guest

This is not an automated script dont user this instead of there are so manu available based on javascript

Nikhil Patel.

Posted on 13.05.2011 00:13 by guest

To find the absolute path:

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>

1. Copy and paste the above code in a blank page
2. Save it as absolutepath.php
3. Upload it via FTP to the location where you intend to install your images for the slideshow
4. Open your favorite browser and enter the URL to point to this file:
- Example: http://www.your-site.com/absolutepath.php
5. That's it, you should have your absolute path displayed in the screen.

Found these instruction on: http://forum.mamboserver.com/showthread.php?t=80307

Posted on 23.04.2011 17:36 by guest

This code exposed a weird problem under Snow Leopard:\

If there's no /etc/php.ini, this code works fine. If there is, the PHP code prints out at the top of the page, beginning with "init()) != '') { header('HTTP/1.1 500 Internal Server Error'); ..." followed by an empty picture reference (question mark) and the First | Previous Next | Last anchors.

This prevents this nice little piece of code from working on properly configured commercial hosts. I would REALLY like to use it, but I don't know nearly enough about PHP admin/setup to solve this problem for myself.

Anyone having a solution, please email me at tomdeboni@comcast.net.

Thanks!

Posted on 23.04.2011 09:32 by guest

it won't work automatically....

Posted on 15.04.2011 14:55 by guest

Sorry i'm not Php programmer. Can nobody tell me in line 6 & 8 and example for me.

Posted on 03.02.2011 11:56 by guest

useful my site thank...

Posted on 10.12.2010 17:33 by guest

This blows to be honest....

Posted on 10.12.2010 01:25 by guest

Steve, I can't get this to load the image directory. Tried checking root and www settings on line 6 & 8, still no go? Help!

Posted on 29.11.2010 08:25 by guest

Thx, works fine only one problem. When U klick next the page uppdates, so itt will jump back to the top of the page. How can i fix?

Posted on 20.09.2010 15:22 by guest

I like this very much. I am a php programmer and Thank you very much for this code.

Posted on 17.07.2010 09:50 by steve

You will have to use Javascript setTimeout() for this.
It will be something along these lines:


(inside javascript tag at the bottom of the page)
setTimout("window.location.href='?img=<?=$next;?>';", 3000); // 3 secs

Posted on 17.07.2010 06:09 by guest

Nice job.

Any chance to have the images rotate automatically in an given interval?

Thanks for your reply,
Chris.

Posted on 15.07.2010 18:11 by guest

Good !!!! Thanks a lot

Posted on 10.06.2010 00:46 by steve

Reading for the text widget at the Wordpress.com site, I believe you
can add an iframe with the URL as src. Then the gallery will be displayed.
Just guessing, I am not a Wordpress user.

Posted on 09.06.2010 22:34 by guest

Can anybody help explain how you would do #6 in wordpress? How would you access this php from a text widget in your sidebar?

Posted on 09.05.2010 08:01 by steve

Here is a working page with the script:
http://bmwhandlebarrisers.com/gallery/idigallery.php

Posted on 04.02.2010 19:33 by guest

A demonstration of what the end result will look like would be nice :)

Posted on 23.01.2010 13:34 by zamg0d1

Can I add this to my own existing site?

Posted on 05.11.2009 19:59 by guest

Thanks a lot!

Posted on 30.11.2008 05:07 by guest

Not bad