Code to access first image of a sub-gallery

I'm using the 'example' theme and I'm trying to figure out how to get the first image of an album.

Well what I'm REALLy trying to do is to skip the second level album page and just jump right in to the image view.
Example:
from zenphoto gallery list I click on a gallery that has a sub gallery. Instead of showing the list of galleries upon clicking the thumbnail, I want it to simply go straight to displaying the first image of the list. For this, I figured I would have the thumbnail of the sub gallery to have a url to the first image instead of the url to the gallery itself.

Confused? Me too :)

Comments

  • A little more context to my request above:

    in template-functions.php (in 'example' theme) there is a method 'getAlbumLinkURL' I would like to have a check so it appends the first image to the url if it is a sub album.

    if (is a sub album){
    //get the first image
    //append it to the end of the url
    // eg. return <zenpath>/index.php?album=ALBUM%2FSUBALBUM&image=IMGNAME.JPG
    }
    else
    {//do what it does now
    return rewrite_path("/" . pathurlencode($_zp_current_album->name) . "/",
    "/index.php?album=" . urlencode($_zp_current_album->name));
    }
  • Do you want the thumbnails of the images or the actual first image? I am not clear on what you are trying to do. Are you going to inhibit the thumbnails of the subalbum? Or do you want to skip the image thumbnails pages?

    You can create a custom function to do this and replace the two getAlbumLinkURL() calls with it:

    `function getFirstImageLinkURL() {

    global $_zp_current_album, $_zp_current_image;

    $images = $_zp_current_album->getImages(); // array of images in sort order

    $_zp_current_image = $images[0]; // first image

    return getImageLinkURL();

    }`
  • sorry for not being clear. this is almost what I need (i know i'm close).
    The album page is iterating through the albums ('while(next_album()'). what I need is for the thumbnails for the sub albums to load but to link to the first image in the sub album instead of the sub album page with the thumbnails of the images inside (essentially skipping this page).
  • sbillard - THANKS! I got it. all I did was modify the return line to append the image. seem the array was returning a string an not an object.

    return getAlbumLinkURL(). "&image=" . $_zp_current_image;

    I removed the subalbum in the breadcrumb and I'm good to go.
    Thanks for your quick response.
Sign In or Register to comment.