Hi folks,
I build a lot of Flash websites, and usually use SlideShowPro if I need some simple image capacities (as it's updatable via XML). Sometimes you need more control over these images though - drag and drop re-ordering, auto-thumbnailing etc would all be a great boon if available to a client....
So, I was just wondering how hard it would be to hook Zenphoto up to Flash with some actionscript?
Obivously you would need one or two different components in Flash to display the images - maybe a thumbnail style gallery, and a slideshow type holder.... the other problem I guess is that the coding would probably be much easier if there was something more concrete for the Flash to hook up to, like a feed or xml file?
Not going to go into any detail as I'd be interested to hear what you might think about this?
Could Zenphoto even be hooked up directly to SlideShowPro? (It's been done already with iPhoto, Coppermine et al)
Cheers
3stripe
Comments
As a starting point... I was trying to work out if gallery info is stored in a flat file anywhere, or if it's found by scanning each directory for usable images? (I'm thinking it's the latter)
The info in the database is only for storing metadata about files; it is not guaranteed to exist if the file exists and therefore can't be trusted. This is because changes in the filesystem are only reflected in the database when objects are loaded, and deletions are only noted when the database is garbage collected, which happens rarely. This is called lazy evaluation, and it makes everything simpler and more efficient in this case, and it's used all over zenphoto -- images aren't generated until they're first requested, for example.
Hope that gives a little insight into the backend. Let me know if you have any more questions.
Talking about SlideShowPro integration first as it's easier:
Tthere is already a php script for automatic generation of an XML file by reading a directory (see below)...
Only thing we would need to do is work out a way to generate permanent thumbnails which were sitting side-by-side with the large versions (or could they still be cached?)
`<?php<br />
/* -------------------------------------------------
Title: SlideShowPro Dynamic XML File Generator
Purpose: Generates an xml file of albums and
their photos for use with Todd Dominey's
SlideShowPro - http://www.slideshowpro.com
Author: Brian Sweeting - http://www.sweeting.net
Modified: 16 Feb 2005
License: None. Feel free to make any changes or
improvements you like.
.
Example Directory Structure:
.
/photogallery
/album1
/lg
/tn
------------------------------------------------- */
//
//Directory where all album folders are located
$albums_dir = '/path/to/directory/containing/photo/albums';
//
//Get directories for photo albums
$d = dir($_SERVER['DOCUMENT_ROOT'].$albums_dir);
while (false !== ($entry = $d->read())) {
if(is_dir($d->path.'/'.$entry) && $entry != '.' && $entry != '..') {
$albums[] = $entry;
}
}
$d->close();
//
//Send content type as text/xml so the browser knows it's an xml file
header('Content-type: text/xml');
//
//Generate xml data
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '';
for($i = 0; $i < sizeof($albums); $i++) {
$album_title = ucwords(eregi_replace('_',' ',$albums[$i])); //Remove underscores and capitalize the words in the album directory
echo ' ';
//
// Load all photos for this album into an array, then print them out
$album_photos_dir = $_SERVER['DOCUMENT_ROOT'].$albums_dir.'/'.$albums[$i].'/tn';
$dh = opendir($album_photos_dir);
while (false !== ($filename = readdir($dh))) {
if (eregi("jpg",$filename)) {
$album_photos[] = $filename;
}
}
for($j = 0; $j < sizeof($album_photos); $j++) {
echo '
}
echo ' ';
}
echo '';
?>`
See the example here.
`
<?php
if (!defined('ZENFOLDER')) { define('ZENFOLDER', 'zp-core'); }
define('OFFSET_PATH', 0);
header('Content-Type: application/xml');
require_once(ZENFOLDER . "/template-functions.php");
$themepath = 'themes';
function fixRSSDate($bad_date) {
$rval = FALSE;
$parts = explode(" ", $bad_date);
$date = $parts[0];
$time = $parts[1];
$date_parts = explode("-", $date);
$year = $date_parts[0];
$month = $date_parts[2];
$day = $date_parts[1];
$rval = date("r",strtotime("$day/$month/$year $time"));
return $rval;
}
$albumnr = sanitize_numeric($_GET['albumnr']);
$albumname = sanitize(urldecode($_GET['albumname']), true);
$albumfolder = sanitize(urldecode($_GET['folder']), true);
$host = htmlentities($_SERVER["HTTP_HOST"], ENT_QUOTES, 'UTF-8');
// check passwords
$albumscheck = query_full_array("SELECT * FROM " . prefix('albums'). " ORDER BY title");
foreach($albumscheck as $albumcheck) {
if(!checkAlbumPassword($albumcheck['folder'], $hint)) {
$albumpasswordcheck= " AND albums.id != ".$albumcheck['id'];
$passwordcheck = $passwordcheck.$albumpasswordcheck;
}
}
if ($albumname != "") {
$albumname = " (".$albumname.")";
}
if(getOption('mod_rewrite')) {
$albumpath = "/"; $imagepath = "/"; $modrewritesuffix = getOption('mod_rewrite_image_suffix');
} else {
$albumpath = "/index.php?album="; $imagepath = "&image="; $modrewritesuffix = ""; }
?>
<?php echo htmlspecialchars(getOption('gallery_title')).htmlspecialchars($albumname); ?>
<?php echo "http://".$host.WEBPATH; ?>
Zen Photo Media RSS
http://blogs.law.harvard.edu/tech/rss
en-us
ZenPhoto RSS Generator
Copyright 2007 thestable.info, All Rights Reserved
<?php
$size = sanitize_numeric($_GET['size']);
if(is_numeric($size) && $size != "" && $size < getOption('feed_imagesize')) {
$s = $size;
} else {
$s = getOption('feed_imagesize'); // uncropped image size
}
$items = getOption('feed_items'); // # of Items displayed on the feed
db_connect();
if (is_numeric($albumnr) && $albumnr != "") {
$albumWhere = "images.albumid = $albumnr AND";
} else if (isset($_GET["folder"])) {
$albumWhere = "folder LIKE '".$albumfolder."/%' AND ";
} else {
$albumWhere = "";
}
$result = query_full_array("SELECT images.albumid, images.date AS date, images.filename AS filename, images.desc, images.title AS title, " .
"albums.folder AS folder, albums.title AS albumtitle, images.show, albums.show, albums.password FROM " .
prefix('images') . " AS images, " . prefix('albums') . " AS albums " .
" WHERE ".$albumWhere." images.albumid = albums.id AND images.show=1 AND albums.show=1 ".
" AND albums.folder != ''".$passwordcheck.
" ORDER BY images.mtime DESC LIMIT ".$items);
foreach ($result as $images) {
$imagpathnames = explode('/', $images['folder']);
foreach ($imagpathnames as $key=>$name) {
$imagpathnames[$key] = rawurlencode($name);
}
$images['folder'] = implode('/', $imagpathnames);
$images['filename'] = rawurlencode($images['filename']);
$ext = strtolower(strrchr($images['filename'], "."));
$images['title'] = htmlspecialchars($images['title'], ENT_QUOTES);
$images['albumtitle'] = htmlspecialchars($images['albumtitle'], ENT_QUOTES);
$images['desc'] = htmlspecialchars($images['desc'], ENT_QUOTES);
?>
<?php echo $images['title']." (".$images['albumtitle'].")"; ?>
<?php echo 'http://'.$host.WEBPATH.$albumpath.$images['folder'].$imagepath.$images['filename'].$modrewritesuffix ;?>
<?php echo $images['title'] ?>
<?php echo $images['albumtitle']; ?>
" type="image/gif" />
" type="image/gif" />
<?php } ?>
`
This code is merely an updated rss feed which generates a feed that slideshow pro can understand. Hope this helps others.