Support » Plugin: Simple Lightbox » Another “triggering” question

  • Resolved REngland

    (@rengland77)


    I’ve looked through the forum, and your “manual activation” page… but I don’t know enough php to get this to work. I’m using ACF (grabbing the image URL) and a genesis function to add this below normal content. Trying to make the word “Bio” link to an image popup. What am I missing?? Would trying to link text to a lightbox even work? Thanks.
    (this page isn’t live yet.)

    `<ul class=”staff-links”>
    <?php
    if( have_rows(‘instructor’) ):
    while ( have_rows(‘instructor’) ) : the_row();
    $image = get_sub_field(‘biography_photo’);
    if ( function_exists(‘slb_activate’) ) {
    $image = slb_activate($image);
    }
    ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yikes! sorry about that code formatting mess. Not used to trying to post code here!

    Plugin Author Archetyped

    (@archetyped)

    Hi, please provide an updated code sample (see WordPress’ documentation for instructions), and I would be glad to take a look.

    SLB works with any valid link, regardless of whether the link contains text or an image.

    However, from what I can see from the above snippet, it looks like you may be passing slb_activate() an image URL only. As per SLB’s manual activation documentation, it’s important to note that slb_activate() is used on content “containing links to be activated”, not bare URLs.

    You can also use the example code included on that page for reference, as it demonstrates building an HTML link, and then passing the link through slb_activate() to activate it.

    Ugh, you’re right. I was trying to activate an image url.

    If feeling friendly, here’s my mess (snippet). Back to the drawing board!

    <?php 
    		if( have_rows('instructor') ):
    		while ( have_rows('instructor') ) : the_row();
    		$image = get_sub_field('biography_photo'); 
    		if ( function_exists('slb_activate') ) {
    			$image = slb_activate($image);
    		}
    		?>
    
    	 		<li>
    	 			<span class="bio-name"><?php the_sub_field('name'); ?></span>
    	 			<span class="bio-links">
    	 				<a href="<?php echo $image; ?>">Bio</a> | 
    	 				<a href="<?php the_sub_field('bean_app_link'); ?>" target="_blank" rel="noopener noreferrer">Bean app</a>
    	 			</span>
    	 		</li>
    
    	 	<?php endwhile;
    	        else :
    	            // no rows found
    	        endif; 
            ?>
    Plugin Author Archetyped

    (@archetyped)

    Thanks for reposting the code snippet. It looks like the “Display post thumbnail in lightbox” example code in SLB’s documentation is a good fit for your needs.

    1. The $thumbnail['url'] variable contains the link’s URL, which you can replace with your ACF-based URL.
    2. The $thumbnail['link'] variable is where the HTML link is built.
    3. Once the full link is built, you can echo it into your HTML in place of the existing link with PHP-inserted URL.

    Post your updated code snippet if you’re having any problems, and I would be glad to take a look.

    Thank you for your help, I got it working. 🙂

    Plugin Author Archetyped

    (@archetyped)

    Awesome, glad to hear it 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.