Linking directly to a photo from Album thumbnail

I am curious if it is possible to link directly to a photo from the main Album. This would skip opening the album to view all of it's thumbnails, then clicking on a thumbnail to view it.

This would force the user to use the previous/next buttons to view an album.

Any suggestions?

Comments

  • trisweb Administrator
    Yep! If you want the album to link directly to the first image in the album, just call next_image() inside the while(next_album()) and call its printImageThumbnail (or whatever, I'm not looking at the code). You'll get thumbnails of the first image in each album linking directly to that image, bypassing the album page.
  • That's great! Thank you!
  • hey, tris :)

    i got close to that solution, but i'm really not a php programmer and i'd much appreciate your (or anyone's) help.

    so here's how i understood your instructions:

    ``

    and here's what i got:

    `
    • Afinidades Eletivas
    `

    i surely missed something, but i can't figure out what.
  • I'm in need of the same functionality, and I couldn't get this to work either. Any suggestions?

    Thanks.
  • trisweb Administrator
    There are actually several ways to do this, but I'll give you one example.

    In index.php, look for something like this (the album thumbnail):

    `" title="View album: <?php echo getAlbumTitle();?>"><?php printAlbumThumbImage(getAlbumTitle()); ?>`

    You want to get the first image in the album, and then get the link to that, so do this instead:

    `<?php set_context(ZP_IMAGE); $_zp_current_image = $_zp_current_album->getImage(0); if (!$_zp_current_image) continue; ?>

    getImageLink(); ?>"/><?php printImageThumb(getImageTitle()); ?>

    <?php set_context(ZP_ALBUM); ?>`

    I've just tested this and it works great. One other note - you'll probably also want to edit the image.php for your theme and remove the breadcrumb link to the album, in case you want to hide it completely.
  • I did something like this but with a different approach because for some albums i wanted to go straight to the first image and for some albums just go to the album page.

    eg on http://www.bertsimons.nl/zenphoto/ 'paper sculptures' goes to the album page and 'furniture' goes straight to the first image on the image page.

    did this like this. in the customdatafield for the albums I insert 'noalbumpage' to define this album as a noalbumpage album cq go straight to the first image.

    then on album php at the top I wrote this, actually just a conditional redirect to the first image;

    `<?php <br />
    global $_zp_current_album;

    $albumpagecheck= getAlbumCustomData();

    $albumpagecheck = substr_count($albumpagecheck,"noalbumpage");

    if($albumpagecheck==1){

    $image = $_zp_current_album->getImages();

    $first = $image[0];

    $album = getAlbumLinkURL();

    $album= str_replace(WEBPATH, "", $album);

    $path=rewrite_path("index.php?album=" . $album ."&image=".$first);

    $host = $_SERVER['HTTP_HOST'];

    header( "Status: 301 Moved Permanently" );

    header( "Location:http://$host/$path" );

    exit(0);

    }?>`
    `

    ps the breadcrumb stays intact!
  • trisweb Administrator
    Nice use of the custom data field! I like that solution...
  • thanks trisweb, it worked great. Appreciate the help.
  • This is almost what I would like. The only thing I would like extra is not to get the first image by ID, but the manually sorted first image in the album. is this possible? and would someone know how to accomplish that?

    thanx much!
  • I'm a ZenPhoto newbie, and I am DYING to get BertSimons solution to work, but I'm having problems getting it to work.

    First off, is this designed to work with mod_rewrite on or off? When it's on (which I don't want for my set-up), it almost works, but adds an extra "/" between the host and the path. When mod_rewrite is off, it doesn't return any image information in the link, just the album ID.

    Any advice appreciated!!!!
  • Hmmm... got it working with mod_rewrite on by taking out the forward slash "/" between $host and $path in the third line from the bottom

    header( "Location:http://$host/$path" );
    to
    header( "Location:http://$host$path" );

    but can't get it working with mod_rewrite off. Once again, any advice appreciated!
  • Got it working with mod_rewrite turned off. At least it's working on localhost on my own machine. Haven't tested it out on my server yet. In any case, here's the revised code that seems to be working:

    '
    <?php
    global $_zp_current_album;
    $albumpagecheck= getAlbumCustomData();
    $albumpagecheck = substr_count($albumpagecheck,"noalbumpage");
    if($albumpagecheck==1){
    $image = $_zp_current_album->getImages();
    $first = $image[0];
    $album = getAlbumLinkURL();
    $album= str_replace(WEBPATH, "", $album);
    $path= (WEBPATH . $album ."&image=" . $first);
    $host = $_SERVER['HTTP_HOST'];
    header( "Status: 301 Moved Permanently" );
    header( "Location:http://$host$path" );
    exit(0);
    }?>
    '
Sign In or Register to comment.