Support » Themes and Templates » the_post_thumbnail in a popup window

  • Resolved derrickallen

    (@derrickallen)


    Hey Gang!
    I’m currently using code, to link the post thumbnail to it’s full size image,from this article:

    http://codex.wordpress.org/Function_Reference/the_post_thumbnail
    Section: Post Thumbnail Linking to Large Image Size.
    This example links to the “large” Post Thumbnail image size and must be used within The Loop.

    The code is:

    <?php
     if ( has_post_thumbnail()) {
       $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
       echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
       the_post_thumbnail('thumbnail');
       echo '</a>';
     }
     ?>

    This causes the photo to link to it’s full size but moves the page forward to its own page for the picture and then the reader has to go back. Is there a way to call the post thumbnail and make it popup in it’s own browser window or even better, in its own pretty popout window without being a browser? I’ve been looking at the csspopout.js stuff that’s out there but I can’t figure out how to incorporate it with the functions above. Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hrmm no takers yet. Ok.

    Do we think maybe there’s a better way to pull up the_post_thumbnail so that it’s easier to make it a popout?

    esmi

    (@esmi)

    Forum Moderator

    Try looking for a suitable lightbox plugin.

    FINALLY got this working. I installed WP jQuery Lightbox.

    Then I just inserted the lightbox tag into the existing a href of the PHP code I was using before and the images starting hyperlinking to the lightbox instead of the full page. yay 🙂

    <?php
     if ( has_post_thumbnail()) {
       $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
       echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" rel="lightbox">';
       the_post_thumbnail('thumbnail');
       echo '</a>';
     }
     ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘the_post_thumbnail in a popup window’ is closed to new replies.