Topic: load images directly from ftp

Hello, is there any possibility to make simpleviewer reading images directly from the directory on ftp without using SV-Builder-PRO ? It will be very helpfully for me, my client want to add images by hersef and she will not use image description, she will only give name like 1.jpg 2.jpg to the images to set the order for the gallery, what should I do to make SV display images without building a gallery in SV builder pro ?

Thanks!

Re: load images directly from ftp

what should I do to make SV display images without building a gallery in SV builder pro ?

You could use PHP to dynamically generate an XML file on-the-fly to display all images in a certain directory.
Your web server would have to have PHP installed.
Put the following code into a file named 'gallery.php' and place the file in your gallery folder:

<?php
function GetDirArray($folder)
{
    $handle=opendir($folder);
    while ($file=readdir($handle))
    {
        if ($file!="." && $file!="..")
        {
            $ret[count($ret)]=$file;
        }
    }
    closedir($handle);
    sort($ret);
    return $ret;
}
$gallery=GetDirArray('images');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<simpleviewergallery title="SimpleViewer Gallery">';
for ($i=0; $i<sizeof($gallery); $i++)
{
    echo '<image imageURL="images/'.$gallery[$i].'" thumbURL="images/'.$gallery[$i].'" linkURL="" linkTarget="">';
    echo '<caption></caption>';
    echo '</image>';
}
echo '</simpleviewergallery>';
?>

Next, use the following embedding code to use the PHP file as the gallery's XML file:

<!--START SIMPLEVIEWER EMBED.-->
<script type="text/javascript" src="svcore/js/simpleviewer.js"></script>
<script type="text/javascript">
var flashvars={};
flashvars.galleryURL="gallery.php";
simpleviewer.ready(function () {
simpleviewer.load("sv-container", "100%", "100%", "222222", true, flashvars);
});
</script>
<div id="sv-container"></div>
<!-- END SIMPLEVIEWER EMBED -->

Now, when the gallery is viewed, SimpleViewer will display all images in the gallery's 'images' folder.

Steven Speirs
SimpleViewer Support Team.

Re: load images directly from ftp

Oh thanks! but how will SimpleViewer sort the images ? by name, date of upload or ? I will test it now.

---

I have tested it and it seems that is doesnt work, I have placed it here:

http://www.angelsdecor.be/nl/producten/test/

I did what you wrote but my gallery doesnt display...

--

I have packed all files which are located in " /nl/producten/test/ " so you can see if there are any problems in my files, you can download this pack here:

http://www.angelsdecor.be/nl/producten/test/test.rar

its only 1 MB, please check it if you have some time, thank you!

Last edited by mastercobra (2011-06-06 21:02:41)

Re: load images directly from ftp

The embedding code I posted above is for the current version (v2.1.3) and you are using v2.1.2.
Please upgrade SimpleViewer Pro by replacing the 'svcore' folder in your gallery with the 'svcore' folder from the SimpleViewer Pro download package ('simpleviewer_pro_213/web/svcore/').
Upgrades are free within the same major version number so you can download the most recent version by using the link in your purchase email.

Alternatively, you could change your embedding code to:

<!--START SIMPLEVIEWER EMBED.-->
<script type="text/javascript" src="svcore/js/simpleviewer.js"></script>
<script type="text/javascript">
var flashvars={};
flashvars.galleryURL="gallery.php";
jQuery(document).ready(function () {
SV.simpleviewer.load("sv-container", "100%", "100%", "222222", true, flashvars);
});
</script>
<div id="sv-container"></div>
<!-- END SIMPLEVIEWER EMBED -->

However, the upgrade is free and several bugs have been fixed since v2.1.2 so it would be beneficial for you to use v2.1.3.

Steven Speirs
SimpleViewer Support Team.

Re: load images directly from ftp

I have changed the code but didnt upgraded yet, I get now this:

http://www.angelsdecor.be/nl/producten/test/

what can be the problem ?

anyway I have forgot the email address which I have bought the version of SimpleViewer, can you check the payment from officexl@hotmail.com or em@v-d.be ? it was one of them... thank you!

---

Cleared cache of my browser and now it works, thanks!

Last edited by mastercobra (2011-06-07 14:38:05)

Re: load images directly from ftp

I see you have changed your embedding code as I suggested and your gallery now works and displays the images correctly in the Flash Player.
If you are referring to the 'Gallery XML Not Found.' message in the Mobile Player, then this should be rectified as soon as you upgrade the 'svcore' folder to the v2.1.3 version.
If you cannot find your purchase email, please fill in this form to receive a new link: http://simpleviewer.net/support/admin/upgrade.html

Steven Speirs
SimpleViewer Support Team.

Re: load images directly from ftp

Ok thank you, I will continue this with the older version, one question else, how to make the gallery view thumbnails below the main picture like here:

http://www.angelsdecor.be/nl/producten/bloemen/

I have on this moment:

http://www.angelsdecor.be/nl/producten/test/

Re: load images directly from ftp

Add thumbPosition="BOTTOM" as an attribute in the opening <simpleviewergallery> tag in the 'gallery.php' file.
ie. Use:

<?php
function GetDirArray($folder)
{
    $handle=opendir($folder);
    while ($file=readdir($handle))
    {
        if ($file!="." && $file!="..")
        {
            $ret[count($ret)]=$file;
        }
    }
    closedir($handle);
    sort($ret);
    return $ret;
}
$gallery=GetDirArray('images');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<simpleviewergallery title="SimpleViewer Gallery" thumbPosition="BOTTOM">';
for ($i=0; $i<sizeof($gallery); $i++)
{
    echo '<image imageURL="images/'.$gallery[$i].'" thumbURL="images/'.$gallery[$i].'" linkURL="" linkTarget="">';
    echo '<caption></caption>';
    echo '</image>';
}
echo '</simpleviewergallery>';
?>
Steven Speirs
SimpleViewer Support Team.

Re: load images directly from ftp

Everything works fine, thanks!

Re: load images directly from ftp

Hey, the gallery is working fine but there is one problem, the images arent sorted by name, I have added 77 images which have name from 1 to 77.JPG but they arent displayed by this sort.... what should I do ?

http://www.angelsdecor.be/nl/producten/decoratie/

Re: load images directly from ftp

The easiest solution would be to rename the first 9 images from 1.jpg -> 01.jpg, 2.jpg -> 02.jpg, etc.

Steven Speirs
SimpleViewer Support Team.

Re: load images directly from ftp

Works, thank you.