• 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

    (@espurrpuff)

    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 7 years, 7 months ago by moosecat.
    • This reply was modified 7 years, 7 months ago by moosecat.

    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.