![]() |
|
Limit latest images to x album - 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: Limit latest images to x album (/thread-2072.html) |
Limit latest images to x album - osakamojo - 2008-01-12 Hi there. Great photo gallery, I really love it. Like many people though I am wanting to call thumbnails of gallery images from pages outside of the Zenphoto directory (linking to the gallery). I got the the latest images working great with this code (found after trawling the forums): <?php $images = getImageStatistic(6, "latest"); foreach ($images as $image) { $imageURL = getURL($image); echo '<a href="'.$imageURL.'" title="View image: ' . $image->getTitle() . '"><img src="' . $image->getThumb() . '" alt="' . $image->getTitle() . "\"/>\n"; } ?> This gives me the latest 6 photos from the whole gallery. This works fine, but I what I really want is to limit the latest images to those of a particular album. How would I go about doing that? It must be possible, I just don't know enough about programming in general to make it happen. Can anyone help me out? Thanks! Limit latest images to x album - acrylian - 2008-01-12 That's way to complicated anyway. We already have a function called printLatestImages for this...Please see the functions guide on www.zenphoto.org/documentation. Limiting the imageStatistic to an album is not possible at the moment, but sounds like a good idea. Since it's not that difficult to implement I will get this as an option into the next nightly build. Limit latest images to x album - BertSimons - 2008-01-12 I did this like this: for the latest 6 in the album you are cuurently viewing: ` <?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); $images = getImageStatistic($photosNumber, "latest"); $album = $_zp_current_album->getFolder(); $x = 1; foreach ($images as $image) { $imageURL = getURL($image); $check = substr_count($imageURL,$album); if ($check == 1) { $check = substr_count($imageURL,"flv"); if ($check == 0) { echo '<a href="'.$imageURL.'" title="View image: ' . $image->getTitle() . '">[img]' . $image->getCustomImage(null, 30, 30, null, null, null, null) . '[/img]getTitle() . ""/>"; }else{$x=$x-1;} } else {$x=$x-1;} if ($x++ >= 6) { break; } }?> ` and for the latest 6 images in a specific folder you can put the name in the fourth line (the name of the folder on the server's disk in caseyou have changed the title) ` <?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); $images = getImageStatistic($photosNumber, "latest"); $album = "specificfolder"; $x = 1; foreach ($images as $image) { $imageURL = getURL($image); $check = substr_count($imageURL,$album); if ($check == 1) { $check = substr_count($imageURL,"flv"); if ($check == 0) { echo '<a href="'.$imageURL.'" title="View image: ' . $image->getTitle() . '">[img]' . $image->getCustomImage(null, 30, 30, null, null, null, null) . '[/img]getTitle() . ""/>"; }else{$x=$x-1;} } else {$x=$x-1;} if ($x++ >= 6) { break; } }?> ` it is not very nice code becuase it has to go trough aall your imeges and if you have many it can be a bit slow Limit latest images to x album - acrylian - 2008-01-12 FYI: I have submitted an update for getImageStatistic and its related functions that probably will be in one of the next svn. |