Title: Gallery w/Lightbox Support
Last modified: April 6, 2017

---

# Gallery w/Lightbox Support

 *  [moosecat](https://wordpress.org/support/users/espurrpuff/)
 * (@espurrpuff)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/gallery-wlightbox-support/)
 * Hi all! I’m in the process of developing my site with Make, but there’s one feature
   that I feel is lacking. I love the gallery feature and how it looks. But, I’d
   really love if there was an option to make it function more as a gallery. Right
   now I can put images, and have them open links, but there’s no simple way to 
   just have it open the image in an expanded view (e.g. Lightbox). I think this
   would be a great feature to have.
 * Right now, it uses onclick to open the links, instead of a normal link, and I’m
   not sure how to get that working with any lightbox plugins. I’m not very savvy
   with js, so I’m not sure how to get the functionality I’d like, while also keeping
   the current functionality.
 * If I’m just somehow missing a feature that already exists, any guidance would
   be appreciated.
 * Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [moosecat](https://wordpress.org/support/users/espurrpuff/)
 * (@espurrpuff)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/gallery-wlightbox-support/#post-9008487)
 * Update: I’ve somehow conquered the PHP demon, and gotten a solution to this (
   though I cannot guarantee it’s the best solution as I’m inexperienced). Basically,
   Lightbox plugins don’t work with onclick. They require a normal link, so I needed
   to find a way to do that.
 * I’m not sure how to share the code I’ve done, and I’m not entirely sure it’s 
   the best solution to begin with, but it works for me. So, I’ll try to share what
   I’ve done below.
 * **Functionality/Instructions:**
    -A new checkbox added in gallery item settings
   called “Open Image”. This can be done in inc/builder/sections/gallery/definition.
   php by finding all instances of open-new-tab and duplicating the code/changing
   to open-image.
 * -When checked, the get_gallery_item_onclick function will return blank (any link
   in the link box will be ignored). This can be done in inc/builder/sections/section-
   front-end-helpers.php in the ttfmake_builder_get_gallery_item_onclick function
   by adding:
 *     ```
       if (isset( $item['open-image'] ) && $item['open-image'] === 1) {
       return '';
       }
       ```
   
 * Make sure this is below where $item is set.
 * Then, you’ll want to add a new function just below that function to pull the 
   image URL:
 *     ```
       function ttfmake_builder_get_gallery_item_imagelink( $ttfmake_section_data, $i ) {
       	if ( ! ttfmake_builder_is_section_type( 'gallery', $ttfmake_section_data ) ) {
       		return '';
       	}
   
       	$item = $ttfmake_section_data['gallery-items'][$i - 1];
       	$image_src = ttfmake_get_image_src( $item[ 'image-id' ], 'large' );
       	$url = esc_url_raw( $image_src[0] );
   
       	return $url;
       }
       ```
   
 * -When checked, a normal link will be added around the builder-gallery-content
   div, which pulls the item’s image URL. This can be done in inc/builder/sections/
   gallery/frontend-template.php right above the builder-gallery-content div.
 *     ```
       <?php if (isset( $item['open-image'] ) && $item['open-image'] === 1) : ?>
       <a href="<?php echo ttfmake_builder_get_gallery_item_imagelink( $ttfmake_section_data, $i ); ?>">
       <?php endif; ?>
       ```
   
 * And another to close out the a tag, right below the closing tag for builder-gallery-
   content:
 *     ```
       <?php if (isset( $item['open-image'] ) && $item['open-image'] === 1) : ?>
       </a>
       <?php endif; ?>
       ```
   
 * -Because it is a normal image link, lightbox plugins should pick it up.
    -  This reply was modified 9 years, 1 month ago by [moosecat](https://wordpress.org/support/users/espurrpuff/).
    -  This reply was modified 9 years, 1 month ago by [moosecat](https://wordpress.org/support/users/espurrpuff/).
 *  [aggie777](https://wordpress.org/support/users/aggie777/)
 * (@aggie777)
 * [9 years ago](https://wordpress.org/support/topic/gallery-wlightbox-support/#post-9103888)
 * Although this is of no use to me, thank you Liz for posting your findings.
 * I’m sure someone will find it useful, since “make” team abandoned this forum…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Gallery w/Lightbox Support’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/make/1.10.9/screenshot.jpg)
 * Make
 * [Support Threads](https://wordpress.org/support/theme/make/)
 * [Active Topics](https://wordpress.org/support/theme/make/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/make/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/make/reviews/)

## Tags

 * [gallery](https://wordpress.org/support/topic-tag/gallery/)

 * 2 replies
 * 2 participants
 * Last reply from: [aggie777](https://wordpress.org/support/users/aggie777/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/gallery-wlightbox-support/#post-9103888)
 * Status: not resolved