ZenphotoCMS Forum
Get Album's First Image? - 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: Get Album's First Image? (/thread-1163.html)



Get Album's First Image? - Stephane - 2007-02-16

Building upon the success of my previous request, I was wondering if anyone would want to help me out with my next issue.

I'm trying to build my image.php such that clicking the image will send you to the next image and so on, until the last image that would in theory send you back to the first. A simple cycle.

I'm thinking it would be useful in this case to have a function call the first image of the album, and get the URL from that. If there's a simpler way, let me know!




Get Album's First Image? - trisweb - 2007-02-16

I'd skip an abstraction layer for that and go straight for the class--

$firstimage = $_zp_current_album->getImage(0);
does exactly what you want :-)




Get Album's First Image? - Stephane - 2007-02-16

It works! Fantastic!




Get Album's First Image? - lenaluna - 2007-10-19

i have found the code to click on the image to go the next image. now I would like to implement above as well, so the last will get you back to the first image. but I have no idea where to put the bit of '$firstimage' code...




Get Album's First Image? - ruiner - 2011-02-01

How can I get link by id, if the desired image not in current album? The class above isn't working of course.




Get Album's First Image? - acrylian - 2011-02-01

Zenphoto almost never works with the id. It always uses the "name" of an item. To do this you have to setup the album object of the album yourself. See the object model tutorial.




Get Album's First Image? - ruiner - 2011-02-02

I don't want to use the filename, because it's a variable (I can change it anytime), and the id is persistent through the lifetime of image in gallery. I'm trying to make links on images within images (like hotspots).

How can i get any image full link using id?




Get Album's First Image? - sbillard - 2011-02-02

Be very careful how you change the filename, else you may also change the ID if Zenphoto thinks it is a new image.

Anyway, there is no way to create a link which uses the ID as the linked object. Zenphoto works only with album/image names.

If you just want to find an image by id you can always use a SQL SELECT query.




Get Album's First Image? - ruiner - 2011-02-02

Thank you, I'll try.




Get Album's First Image? - ruiner - 2011-02-02

I've ended with the following:

`

function getImageLinkbyID($id) {

$image = query_single_row("SELECT `albumid,filename FROM " . prefix('images') . " WHERE id=" . $id);
$album = query_single_row("SELECT folder FROM " . prefix('albums') . " WHERE id=" . $image['albumid']);

$url = html_encode(getGalleryIndexURL(false)) . "?album=" . $album['folder'] . "%26image=" . $image['filename'];

return($url);
}




Get Album's First Image? - acrylian - 2011-02-02

More elegant would be to use the object model. Regarding names. Don't confuse the title with the name of an item!




Get Album's First Image? - ruiner - 2011-02-06

I have found a problem.

On Mobile Safari (on my ipod touch, or on regular Safari with ipod user-agent) link containing url-encoded '&' symbol (%26) shows following error:

Zenphoto Error: the requested object was not found.
Album: okhotsk_seashore/coastâ„‘=nuklya_cape_sunset.jpg

Is it zenphoto or mobile safari bug?




Get Album's First Image? - sbillard - 2011-02-06

The ampersand really should be encoded & not %26.