i'd like to be able to trigger thumbnail creation via script, after adding a large number of files, to save generating them on the fly. with over 10GB of images & adding about 1GB per month, it makes sense to be able to do this in advance, to keep load down
Comments
`
<?php <br />
require_once("zen/template-functions.php");
$count = 0;
echo 'Loading...
';
while (next_album()):
while (next_image()):
echo ' /
';
$count++;
endwhile;
endwhile;
echo "Finished: Total of $count images.
";
?>
`
I dropped this in zen/* with all the other bits as rebuild.php, stripped out the zen/ path header & ran it, with a ."\n" at the end of the echo line for readability:
php rebuild.php
<.../
Finished: Total of 459 images.
-- in about 10 seconds. i'm a little suspicious as i know i have 9000 images online so far... and only 530 thumbnails in cache/
the first folder it picks up has about 350 images in it, but ZP only gets to the first 30 before heading off to the next ones. this is a pattern - if the album has > 30 images, ZP skips to the next before finishing.
i'd guess there needs to be something like a "next page" in between the next_album and next_image loops...
i can provide debug output or any other info if you let me know what is needed.
you can grab the log from this run as:
http://muse.net.nz/zenphoto/cache/rebuild.log
thanks, scorch
PS i still haven't figured out how/where i can rotate images yet ... is there a how-to somewhere i missed?
`
<?php <br />
require_once("zen/template-functions.php");
$count = 0;
echo 'Loading...
';
$_zp_page = 0;
while (next_album()) {
while (next_image()) {
echo ''."n";
$count++;
if ($count % 20 == 0) echo "
n";
}
}
echo "n
Finished: Total of $count images.
";
?>
`
is it possible to change to run from zephoto/zen/ & then leave it in SVN? that would be a useful addition.
e.g. as http://muse.net.nz/zenphoto/zen/rebuild.php
`
<?php <br />
require_once("template-functions.php");
global $_zp_gallery;
$count = 0;
function loadAlbum($album) {
global $_zp_current_album;
echo "
Processing " . $album->name . "n";
$subalbums = $album->getSubAlbums();
foreach ($subalbums as $folder) {
$subalbum = new Album($album, $folder);
$count = $count + loadAlbum($subalbum);
}
$_zp_current_album = $album;
if (getNumImages() > 0) {
echo "
n";
while (next_image()):
echo ' | ' . "n";
$count++;
endwhile;
}
echo "
Finished with " .$album->name . "n";
return $count;
}
if (isset($_GET['album'])) {
$folder = strip($_GET['album']);
$album = new Album($album, $folder);
$count = loadAlbum($album);
} else {
echo "Processing Galleryn";
$albums = $_zp_gallery->getAlbums();
foreach ($albums as $folder) {
$album = new Album($album, $folder);
$count = $count + loadAlbum($album);
}
}
echo "
Finished: Total of $count images.";
?>
`
If you don't want to do your whole gallery, just pass the file an album parameter with the name of the album you wish to process.
e.g. http://myalbum.zenphoto.com/zenphoto/zen/loadAlbums.php?album=newalbum
Any ideas why? Does anyone have an updated cache script? (I need it for my gallery migration)
Thanks,
grantonstar
The reason I want to pre-cache is to run the Gallery migration utility.