Topic: Auto Flash Slideshow

This script will allow you to point the slideshow to a folder and have it automatically load all the images from it.  Follow the steps below and all you will have to do is upload image to a folder and they will appear in the slideshow.

Step 1
You will need to download this file: auto.zip

Step 2
Unzip the file and open auto.php.  At the very top set $file_dir to the directory you want the gallery to read from.  There are a couple of other options:
$show_titles will allow you to display image titles as captions (without the .jpg)
$omit_chars allows you to set the number of characters to be omited from the beginning of the image title.  So, 01_image_title.jpg will show up as  "image_title" in the caption.  Useful for sorting.
$link_to_image lets you link each slide to the image directly.

Step 3
In your slideshow.html change the following line:

var so = new SWFObject("slideshow.swf", "gallery", "100%", "100%", "7", "#333333");

to

var so = new SWFObject("slideshow.swf?file=auto.php", "gallery", "100%", "100%", "7", "#333333");

Step 4
Now you will need to upload everything to a server that supports php (most do).  The gallery will not work on your local computer.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

Now available in ASP.  Thanks to Charles Harford of ocean-design.co.uk.
Download ASP Version

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

Thanks,
Have other versions? such as PHP...

Re: Auto Flash Slideshow

Please see the original post above.  There is a link to download the php version.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

Great feature.  Can you enter comments for the images with an auto slideshow?

Re: Auto Flash Slideshow

You cannot enter comments, unless you name your images with long, descriptive titles.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

Thanks for the quick reply.  The HTML text feature is really great.  I would be really cool if you would do that in the automated version.  Say with a caption file or something, or atleast the ability to go back and edit the html that's been created by the .php file..

Re: Auto Flash Slideshow

You can always copy/paste into an xml file and then edit the captions.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

I had noticed that there is a way to pass variables (xml files) to the slideshow script in another post.  I am very interested in using the auto.php so that my slideshows can just be automatically created from files in a specific folder.  I have been able to get this to work successfully for webpages with one slideshow, but wish to have multiple slideshows per page, each calling for images using the auto.php script from a different folder of images.

I  have tried to use the auto.php feature for multiple slideshows in one page for each new instance of the slideshow without much success, this is what I tried:

re-named auto.php and updated the renamed newauto.php with new image path
then I called each slideshow out in a separate <script></script> instance on the webpage.

I don't know my failure to get the multiple slideshows to work on one webpage is a function of the auto.php not being able to be renamed for the slideshow to work or some other cause.

Any help or insight you could provide would be much appreciated.

Thanks.

Re: Auto Flash Slideshow

When you re-named auto.php, did you also update the html to point to the new file?  The part that says slideshow.swf?file=auto.php.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

If you want the auto.php file to automatically use photos in the same directory as the auto.php file then set:
$file_dir="./";

Useful if your like me and have your photos set out like so:

images/facilities/library (all photos for library)
images/facilities/technology (all photos for technology)

Then in the flash I link to the category of the page images/facilities/technology/auto.php

Re: Auto Flash Slideshow

I'm not the best coder out there but I had an old function that let me read a directory sorted by last modify date and that is what I wanted for my slideshow so I threw this together. It works great!

<?php
$file_dir="../../Slides/Grandkids"; //change this to a folder name
$link_dir="../Photos"; //change this to a folder name
$show_titles=true; //change to false if you don't want to see the captions
$omit_chars=0; //how many characters to cut off the title's front
$link_to_image=true; //do you want to display links?
$sortOrder="New"; //Left blank the order is standard Rev=reverse New=newest by mod date Old=oldest


print '<?xml version="1.0" encoding="iso-8859-1"?>
    <slideshow  displayTime="8"
                transitionSpeed=".7"
                transitionType="Fade"
                motionType="None"
                motionEasing="easeInOut"
                randomize="false"
                slideshowWidth="480"
                slideshowHeight="350"
                slideshowX="center"
                slideshowY="center"
                bgColor="333333"
                bgOpacity="100"
                useHtml="true"
                showHideCaption="true"
                captionBg="000000"
                captionBgOpacity="40"
                captionTextSize="11"
                captionTextColor="FFFFFF"
                captionBold="false"
                captionPadding="7"
                showNav="true"
                autoHideNav="true"
                navHiddenOpacity="15"
                navX="center"
                navY="315"
                btnColor="FFCC00"
                btnHoverColor="ffffff"
                btnShadowOpacity="70"
                btnGradientOpacity="20"
                btnScale="120"
                btnSpace="50"
                navBgColor="333333"
                navBgAlpha="95"
                navCornerRadius="20"
                navBorderWidth="2"
                navBorderColor="FFFFFF"
                navBorderAlpha="100"
                navPadding="10"
                tooltipSize="8"
                tooltipColor="000000"
                tooltipBold="true"
                tooltipFill="FFFFFF"
                tooltipStrokeColor="000000"
                tooltipFillAlpha="80"
                tooltipStroke="0"
                tooltipStrokeAlpha="0"
                tooltipCornerRadius="8"
                loaderWidth="200"
                loaderHeight="1"
                loaderColor="FF0000"
                loaderOpacity="100"
                attachCaptionToImage="true"
                imageScaling="fill"
                slideshowMargin="0"
                showMusicButton="false"
                music=""
                musicVolume="100"
                musicMuted="true"
                musicLoop="true"
                watermark=""
                watermarkX="625"
                watermarkY="30"
                watermarkOpacity="100"
                watermarkLink=""
                watermarkLinkTarget="_blank"
                captionsY="bottom"
                >';
    //Get each file and add its details to two arrays
    $results = array();
    $handler = opendir($file_dir);
    while ($file = readdir($handler)) {
        if(substr($file, -3) == "jpg" || substr($file, -4) == "jpeg" ){
            $currentModified = filectime($file_dir."/".$file);
            $file_names[] = $file;
            $file_dates[] = $currentModified;
        }   
    }
       closedir($handler);

    //Sort the date array by preferred order
    if ($sortOrder == "New"){
        arsort($file_dates);
    } elseif ($sortOrder == "Old") {
        asort($file_dates);
    } elseif ($sortOrder == "Rev") {
        sort($file_names);
    }else{
        rsort($file_names);
    }
   
    //Match file_names array to file_dates array
    $file_names_Array = array_keys($file_dates);
    foreach ($file_names_Array as $idx => $name) $name=$file_names[$name];
    $file_dates = array_merge($file_dates);
   
    $i = 0;

    //Loop through dates array and then echo the list
    foreach ($file_dates as $file_dates){
        $date = $file_dates;
        $j = $file_names_Array[$i];
        $file = $file_names[$j];
        $i++;
           
                    $tmp_str = '<image img="'.$file_dir.'/'.$file.'" ';
                    if($show_titles){
                        $file_title=substr($file, $omit_chars, strpos($file, ".")-$omit_chars);
                        $tmp_str .= 'caption="'.$file_title.'" ';
                       
                    }
                   
                    if($link_to_image){
                        $link_title=substr($file, $omit_chars, strpos($file, ".")-$omit_chars);
                        $tmp_str .= 'link="'.$link_dir.'/'.$file.'" target="_blank"';
                       
                    }
                   
                        $tmp_str .=" />";
        echo  "$tmp_str";       
    }
print '</slideshow>';
?>

Re: Auto Flash Slideshow

Hello.

thanks for nice script.

btw, I think it is "more" correct to add this:

header("Content-type: text/xml");

to the beginning of the auto.php script.


It is my opinion:)
thanks and good luck!

Last edited by hugl3 (2008-08-30 11:48:07)

Re: Auto Flash Slideshow

hugl3 wrote:

Hello.

thanks for nice script.

btw, I think it is "more" correct to add this:

header("Content-type: text/xml");

to the beginning of the auto.php script.


It is my opinion:)
thanks and good luck!

This script is very easy, but also very useful. Thanks alex wink

Re: Auto Flash Slideshow

This php script was exactly what I was looking for, but I've encountered a problem.  I'm using the player in a dynamic profile page.  So, Joe Blow's profile may have 6 images to display, but Suzy Girlface's page might only have one photo. 

Problem is, if there's only one photo in the defined directory, the slideshow doesn't function properly.  It keeps trying to rotate to the next photo - which isn't there.

I'd love it if I could tell this script to rotate only if there is more than one photo in the directory.  Otherwise, just display the single photo.  Any ideas?

Thanks!

Re: Auto Flash Slideshow

I think I solved my own problem... It might not be the cleanest solution, but it worked for me.  Hopefully it can save someone else a bit of trouble. 

This script counts the number of files in the directory.  Depending on the number that is returned, you can alter the display time for each image.  So technically, the slideshow hasn't paused, it can just be set to display a single for a really long time.

Secondly, if there is only one image in the directory, this script disables showNav in the slideshow - so the user can't hit 'next' and break the slideshow.

Here's the PHP:
$cnt=0;
$dirname="directory";
$dh = opendir($dirname);
while ($file=readdir($dh))
{
$cnt=$cnt+1;
}
closedir ($dh);

$num_files=($cnt-2);

if ($num_files == 1)
    {$disp_time=300;
     $nav_disp="false";
    }
else
    {$disp_time=5;
     $nav_disp="true";
    }

And in the xml, further down the page...

displayTime="'.$disp_time.'"
showNav="'.$nav_disp.'"

Re: Auto Flash Slideshow

is it possible to add the url target with this auto.php?

Re: Auto Flash Slideshow

I wrote to Alex, but if anyone else can help me, that would be great.

I am trying to get the flash sledshow to work the auto.php.
I have several questions. I am trying to do two different slideshows where the photos are in two differetn folders. The these folders are in the folder where the html files, that have the slideshows, will reside.

In the auto.php file, where you can specify the folder:
$file_dir="warehouse";
How exactly do you specify the folder where your images are located?
IS this where you specify where your images are located?

Can I call a different .php file for each slideshow? For instance, evidence.php for photos in the evidence folder and vendor.php for photos in the vendor folder. I assume this can be done if I change what is being called in the html file in this line:
var so = new SWFObject("slideshow.swf?file=evidence.php", "gallery",
"500", "375", "7", "#ffffff");

I am not a coder and would appreciate any help that anyone could provide. Thanks.
David

Re: Auto Flash Slideshow

$file_dir="warehouse";
Yes, this is the path to the folder of images relative to auto.php. So, if in your main folder you have slideshow1/ and in that folder you have images, then you should put $file_dir="slideshow1/images"; in auto.php for the first slideshow.  auto.php should be in the same folder as the html page where you are embedding the slideshow. 

You can create a different auto.php for each new slideshow.  You need to re-name it and put it on the same level as your html page.  If you re-named auto.php to evidence.php, then your code is correct:
var so = new SWFObject("slideshow.swf?file=evidence.php", "gallery",
"500", "375", "7", "#ffffff");

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

Thank you again for your reply and information.
I must be the stupidest person in the world. I cannot get this to work.

My html file and my auto.php file reside in the same folder.
My images are in a folder off of that called warehouse. It is only one folder away from the html and auto.pho files.

This is my html that I am putting in my page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
    <head>
        <title>FlashNifties Flash Slideshow</title>
        <script type="text/javascript" src="flashdetect.js"></script>
        </head>
    <body>

<div id="flashcontent" style="width:435px; height:300px;
background-color:#FFFFFF; border:4px solid #800000;">
            <h1>Oops!</h1>
            <p>It looks like you don't have flash player 6 installed.
            <a href="http://www.macromedia.com/go/getflashplayer" >
            Click here</a> to go to Macromedia download page.
            </p>
    </div>

        <script type="text/javascript">
            var so = new SWFObject("slideshow.swf?file=auto.php",
            "gallery",
"500", "375", "7", "#ffffff");
            so.write("flashcontent");
        </script>

    </body>
</html>

This is my auto.php file (which is what I am calling from the html) that shows the directory call for where the images are located:

$file_dir="warehouse"; //change this to a folder name

Here is a link to the actual page:
http://sondzin.com/icsite/html/evidence.html

I am sorry I am not getting this. I am sure it is somethig that I am not doing correctly.

Thanks,
David

Re: Auto Flash Slideshow

There seems to be some error with your auto.php on or around line 6:
http://sondzin.com/icsite/html/auto.php

Once the above link displays correctly, your slideshow should start working.

Divide each difficulty into as many parts as is feasible and necessary to resolve it.
-- Rene Descartes

Re: Auto Flash Slideshow

pret auto

I just wanted to take the time to thank you for joining and for your contribution.
Great work^^

Re: Auto Flash Slideshow

Well, I upgraded and downloaded and mucked around.  I go the demo with the flowers to work for a while. I am at a bitof a loss as towhy the program will not work.  Obviously my fault, not the program.  Perhaps I'm getting tired.
I hate posting long bits of code, but....

Well, the blog wouldn't let me post the code.  It thinks I'm posting spam.
The only error I get is WHOOPS!  It appears yada yada yada.  Does this thing log any error anywhere?  Windows box at the moment so the obvious places don't exist.

I also tried the ("slideshow.swf?file=./images",
strategy and that failed as well.

Any help appreciated.

Re: Auto Flash Slideshow

One of the problems I encountered was, of course, my problem. I found that the text editor I was using was automatically text wrapping. Even though I turned it off, something remained in the code, though I don't know what it was. However, when I opened the .asp (or .php) file in the editor with text wrap turned off, saved the file and then uploaded it, then it worked.

Re: Auto Flash Slideshow

Can you have two instances of the auto.asp slideshow on the same page? I have two flash slideshows on the same page. One is calkled labs.asp and one is called replicate.asp. In the html for labs, I have this:
var so = new SWFObject("slideshow.swf?file=labs.asp",
But in the html for replicate, I have this:
var so = new SWFObject("replicate.swf?file=replicate.asp",

I have also tried it where both are calling slideshow.swf. I am not even sure what I am doing should work, but neither have worked.
Here is the page in question:
http://investigativeconsultants.com/ipc … ovies.html

The first is working and the second one is not.
Any tricks on putting two slideshows on on page? And I am using auto.asp.

Thanks,
David