ZenphotoCMS Forum
Random Thumbnails as plugin without duplicates - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Random Thumbnails as plugin without duplicates (/thread-2795.html)



Random Thumbnails as plugin without duplicates - alanekilauea - 2008-05-03

Hey there, I just spent the day trying to figure this out and finally got it so thought I would share the wealth here. I am not a programmer so forgive if it seems crude, I did what I needed to get it to work.

I needed to show random images from an album on an external page, but found that the random images can end up with duplicates, so my fix:

<?php zp_load_gallery();
?>

<?php //Random Thumbnails, full size image displayed w/ LightBox
zp_load_album('/Hawaii'); // specify album folder
$imageList = ""; // create image list container
for ($i=1; $i<=8; $i++) {
$randomImage = getRandomImagesAlbum();
$imageName = $randomImage->getTitle();
if (strpos($imageList , $imageName)) { // search image list for particular image name, if image name already exists deincrement and continue loop
$i--;
} else {
echo "
[*]\n";
echo '<a>getSizedImage(getOption('image_size')).'" rel="lightbox[slides]" title="'.htmlspecialchars($randomImage->getTitle(), ENT_QUOTES).'">' .
'<img src="' . $randomImage->getThumb() .
'" alt="'.htmlspecialchars($randomImage->getTitle(), ENT_QUOTES).'"';
echo "/></a>
\n";
$imageList = $imageList .' '. $imageName; //append image name to image list
}
}
?>

And that's it. It shows 8 random thumbnails which open with a lightbox effect.
Cheers,
Alane


Random Thumbnails as plugin without duplicates - alanekilauea - 2008-05-03

Hmm mangled my code, one more try:

` <?php //Random Thumbnails, full size image displayed w/ LightBox

zp_load_album('/Hawaii');

$imageList = ""; // create image list container

for ($i=1; $i<=8; $i++) {

$randomImage = getRandomImagesAlbum();

$imageName = $randomImage->getTitle();

if (strpos($imageList , $imageName)) { // search image list for particular image name, if image name already exists deincrement and continue loop

$i--;

} else {

echo "[*]n";

echo 'getTitle(), ENT_QUOTES).'">' .

'[img]' . $randomImage->getThumb() .

'[/img]getTitle(), ENT_QUOTES).'"';

echo "/>n";

$imageList = $imageList .' '. $imageName; //append image name to image list

}

}

?>`