WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. RogerUsh
    Member
    Posted 1 year ago #

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

    <?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('medium');
       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?

    http://wordpress.org/extend/plugins/simple-lightbox/

  2. Archetyped
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. RogerUsh
    Member
    Posted 1 year ago #

    I've moved on to this jquery plugin:
    http://dimsemenov.com/plugins/magnific-popup/

    Works real solid!

  4. Archetyped
    Member
    Plugin Author

    Posted 1 year ago #

    Glad you found a solution that works for you :)

  5. ChristinaHooper
    Member
    Posted 7 months 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
    Member
    Plugin Author

    Posted 7 months 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

About this Topic