Results 1 to 4 of 4

Thread: Swiss Army control image presentation

  1. #1
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Swiss Army control image presentation

    1) Script Title: Swiss Army Image Slideshow

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...army/index.htm

    3) Describe problem: Love this script!! No so much a problem as wanting to upgrade the functionality. I was wondering if there is a way to control the presentation so that it will get images from a folder in reverse order.

    I use this on a site where I am adding new images all the time and would love to be able to automate to go to that image folder grab the images in reverse order, so my newest images show first rather than either my older images first or having to renumber everything each time I add new photos. My images are labeled 001.jpg, 002.jpg, etc.

    Is this possible? My javascript skills are limited, do have some php skills, but mostly with php4.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Grabbing images from a folder is more a job for PHP. And it's less of an issue which version of PHP you are familiar with than of which version is available to you on the server. This should work in PHP 4 or 5:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="swissarmy.js" type="text/javascript">
    
    /***********************************************
    * Swiss Army Image slide show script  -  John Davenport Scheuer: http://home.comcast.net/~jscheuer1/
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full original source code
    ***********************************************/
    
    </script>
    <script type="text/javascript">
    <?php
    function returnimages(){
    	$dirname = './pics_bak/'; //relative path to image folder
    	$pattern = '#\.(jpg|jpeg|png|gif|bmp)$#i';
    	$files = array();
    	if($handle = opendir($dirname)){
    		while(($file = readdir($handle)) !== false){
    			if(preg_match($pattern, $file)){
    				array_push($files, "\t['" . $dirname . $file . "', '', '']");
    			}
    		}
    		closedir($handle);
    		natsort($files);
    	}
    	return "inter_slide.slides = [\n" . implode(",\n", $files) . "\n];\n";
    }
    
    echo returnimages();
    ?>
    
    inter_slide.slides.reverse(); // reverse the order of the array of images
    
    var preload_ctrl_images=false; //if true, set paths to the control images
    
    //Optional Options for the slideshow:
    inter_slide.slides.no_descriptions=1; //use for no descriptions displayed
    inter_slide.slides.pause=1; //use for pause onmouseover
    inter_slide.slides.fadecolor='#111'; //will set fading images background color, defaults to white
    </script>
    </head>
    <body>
    <script type="text/javascript">
    new inter_slide(inter_slide.slides, 800, 650)
    </script>
    </body>
    </html>
    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    Last edited by jscheuer1; 05-09-2014 at 02:06 AM. Reason: add last line
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John, Thank you, that was exactly what I needed! And so elegant to boot!!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Um, great!

    I just noticed though that I have natsort($files); in there. That takes the array of files and sorts them alpha-numerically as a human would. But I think you said you wanted the actual order in the folder. If so, comment out that line.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Swiss Army slideshow: question about the control buttons
    By nskytlan in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-15-2008, 09:27 PM
  2. Swiss Army slideshow: question about the control buttons
    By courtney in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 12-03-2007, 02:55 AM
  3. Control line spacing on Swiss Army Slide show's buttons
    By Cyn in forum Dynamic Drive scripts help
    Replies: 14
    Last Post: 06-29-2007, 01:15 PM
  4. Swiss Army Image Slideshow
    By wyldflower in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 04-23-2007, 03:34 PM
  5. Swiss Army Image Slideshow
    By kayj in forum Dynamic Drive scripts help
    Replies: 9
    Last Post: 04-10-2007, 03:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •