Member
Member
3stripe   2006-04-24, 13:53
#1
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
Developer
Developer
trisweb   2006-04-25, 06:23
#2
Hmm... something I'll have to think about later. Nothing says it can't be done though, so sure, why not? ;-)
Member
Member
3stripe   2006-04-25, 07:37
#3
Heheh Big Grin

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)
Developer
Developer
trisweb   2006-04-25, 08:44
#4
Yeah, the directory structure is the whole basis for the gallery! Each file found is then given a database entry to store more metadata about it, but that's really just secondary. Part of the elegance of it is that it matches the filesystem so closely... and while that can be slow, it's still (obviously) a tolerable speed, if not surprisingly fast for being filesystem-based ;-)

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.
Member
Member
3stripe   2006-04-25, 09:23
#5
Great, thanks for the lo-down.

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

/* -------------------------------------------------

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 '<gallery>';

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 ' <album title="'.$album_title.'" description="" lgPath="http://'.$_SERVER['HTTP_HOST'].$albums_dir.'/'.$albums[$i].'/lg/" tnPath="http://'.$_SERVER['HTTP_HOST'].$albums_dir.'/'.$albums[$i].'/tn/" tn="" startHere="">';

//

// 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 ' [img]'.$album_photos[$j].'[/img]';

}

echo ' </album>';

}

echo '</gallery>';

?>`
Member
Member
thestable   2008-08-26, 14:45
#6
I know this is an old post but I have a solution.
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 = ""; }

?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title><?php echo htmlspecialchars(getOption('gallery_title')).htmlspecialchars($albumname); ?></title>
<link><?php echo "http://".$host.WEBPATH; ?></link>
<description>Zen Photo Media RSS</description>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<language>en-us</language>
<generator>ZenPhoto RSS Generator</generator>
<copyright>Copyright 2007 thestable.info, All Rights Reserved</copyright>
<?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);
?>
<item>
<title><?php echo $images['title']." (".$images['albumtitle'].")"; ?></title>
<link><?php echo 'http://'.$host.WEBPATH.$albumpath.$images['folder'].$imagepath.$images['filename'].$modrewritesuffix ;?></link>
<description><?php echo $images['title'] ?></description>
<category><?php echo $images['albumtitle']; ?></category>
<media:thumbnail url="<?php echo 'http://'.$host.WEBPATH."/albums/".$images['folder'].$imagepath.$images['filename'] ;?>" type="image/gif" />
<media:content url="<?php echo 'http://'.$host.WEBPATH."/albums/".$images['folder'].$imagepath.$images['filename'] ;?>" type="image/gif" />
</item>
<?php } ?>
</channel>
</rss>
`
This code is merely an updated rss feed which generates a feed that slideshow pro can understand. Hope this helps others.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.