Thumbnail in the previous and next position

I love that feature in flickr. It makes going through the photos much less of an action, and much more fun in general.

Anyone know how to go about this, surely it can't be that hard right?

Comments

  • trisweb Administrator
    Really easy in fact. I was planning on making a theme that used that kind of navigation.

    Basically, it's just [$image]->getPrevImage()->getThumbnail()
    (but you of course have to check if the next/prev image actually exists first).
  • Could you please post the exact code for this, because I would like to have the same function in my new zp-theme and this is one of only two things that are still missing.

    The best would be a simple php-code that i can put into the next/prev-navigation from the default theme:

    `<?php if (hasPrevImage()) { ?>

    ">image

    <?php } ?>`

    and in xxx should be the path to the thumbnail.

    Thanks!
  • trisweb Administrator
    It's hard to do outside the theme functions, so I made some new ones.

    Paste these into template-functions.php. They will be included in future releases, so anything you make with them now should work in the future.

    `function getPrevImageThumb() {

    if(!in_context(ZP_IMAGE)) return false;

    global $_zp_current_album, $_zp_current_image;

    $img = new Image($_zp_current_album, $_zp_current_image->getPrevImage());

    return $img->getThumb();

    }`

    `function getNextImageThumb() {

    if(!in_context(ZP_IMAGE)) return false;

    global $_zp_current_album, $_zp_current_image;

    $img = new Image($_zp_current_album, $_zp_current_image->getNextImage());

    return $img->getThumb();

    }`

    And here's an example of how to use it on the image.php theme page:

    `<?php if (hasPrevImage()) { ?> " title="Previous Image">image" /><?php } ?>`

    Note that I may work on these functions more, adding custom thumb sizes and better checking for next/prev existence, so be prepared to update your themes.
  • Thanks! I'd been hoping for this. If anyone wants to see a demo integration I just threw it in to my template along with get next and previous title functions.

    http://www.reidab.com/photos/nyc2004/IMG_1039.JPG

    Note: I'm in the middle of struggling to make IE not break this layout, so don't use it if you want to actually see anything properly at the above link.
  • Hey there. Thanks for adding this function, but I have a question slash request:

    Can I see a range of thumbnails forwards and backwards of the current image? I want to have a navigation bar at the bottom of the page that shows a range of the photos one has seen and to get a quick look ahead of what's coming.

    I'm not sure if this can be done with the current function, or if I need to write my own. Thanks.
  • I actually just figured it out. I'm crazy tired so there is probably a better way of doing this, but this works: (Put it in image.php)

    <?php
    $currentImageTitle = getImageTitle();
    $thumbRange = 2;
    $iterator = 0;
    $controlInt = 0;

    while(next_Image()) {
    if ($currentImageTitle == getImageTitle()) {
    $controlInt = $iterator;
    }
    $iterator ++;
    }

    $iterator = 0;
    while(next_image()) {
    if(($iterator >= ($controlInt - $thumbRange)) && ($iterator <= ($controlInt + $thumbRange))) {
    echo '';
    echo printImageThumb();
    echo '
    ';
    }
    $iterator ++;
    }
    ?>

    please let me know if this makes or doesn't make any sense. It's 4:30 in the morning and I'm going to bed... g-night
  • jesus, my echoed html got all screwed up. whatever, ya'll know what I meant :)
  • @reidab: I love that theme. It looks terrific. Great work.
  • Yup, reid, your theme is hot, cold and dark though it may be.
  • Hi

    Could anyone explain what is wrong in the above example from afrojas with the echo please? I'm trying it out but hardly know any php.

    Thanks!
  • Look at the stopdesign theme that comes with the distribution. It's image page has thumbs for the next and previous images.
  • Thanks, will check it out.
Sign In or Register to comment.