Simple Lightbox
[resolved] Does not work with featured/thumbnail image (6 posts)

  1. RogerUsh
    Posted 3 years ago #

    In my theme I am using this code to show the featured/thumbnail image of the post:

    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') . '" >';
       echo '</a>';

    But Simple Lightbox does not hook into the code on the front end and the link goes to the image source.

    I tried adding data-slb-active="1" data-slb-internal="0" to the img tag, but it did not work. What is the best way to get Simple Lightbox to work with the featured image?


  2. Archetyped
    Plugin Author

    Posted 3 years ago #

    SLB activates links inside post, page, or widget content. Post thumbnails may be supported in the future however.

  3. RogerUsh
    Posted 3 years ago #

    I've moved on to this jquery plugin:

    Works real solid!

  4. Archetyped
    Plugin Author

    Posted 3 years ago #

    Glad you found a solution that works for you :)

  5. ChristinaHooper
    Posted 2 years ago #

    I did this and it worked for me:

    <?php $FeaturedImage = wp_get_attachment_image_src ( get_post_thumbnail_id ( $post->ID ), 'single-post-thumbnail' );  ?>
                        <?php if ($FeaturedImage) { ?>
                            <div class="ListedImage four alignleft"><a href="<?php echo $FeaturedImage[0]; ?>" rel="slb slb_internal" data-slb-active="1" data-slb-internal="0"><img src="<?php echo $FeaturedImage[0]; ?>" /></a></div>
                        <?php } //End - if there was a featured image ?>
  6. Archetyped
    Plugin Author

    Posted 2 years ago #

    I'm glad you found a solution that worked for you. Just wanted to note that all of SLB's undocumented attributes (e.g. data-slb-internal, etc.) can change at any time, so hardcoding these values could cause unexpected behavior in a future update.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Lightbox
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic