Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1436297

    Do you know of a way to create a gallery using the Content GALLERY ELEMENT – but hide the thumbnails on the page and use a Content BUTTON ELEMENT to open the gallery via a URL link for the button?
    Basically we need a Button to open a lightbox gallery of images on the page, but do not want gallery thumbnails to show within the page content, until the gallery is requested by the visitor.

    #1436300

    and you like to show the gallery first in the lightbox – and then on next click the first gallery-item or does the button click start to show in lightbox the first item – then on click left/right the next images?

    see for example: https://webers-testseite.de/hidden-gallery/

    #1436302

    Hi , thanks for the reply.
    We were trying to make the Gallery open from an ENFOLD Content Button Element on the page, so no gallery thumbnails in the page.
    Gallery images only show when user clicks the Button to view the gallery.

    #1436303

    PS: In your example gallery opens from a link, this is good – we want this effect but to open from a ENFOLD Button Element.

    • This reply was modified 8 months, 3 weeks ago by flatairbag.
    #1436307

    the button is there too!

    It turns out to be very complex if you first want to open the gallery preview in the modal window, and then the items with the next click.

    Example Page :
    give to the button element a custom class f.e.: link_to_lightbox and link to an ID.
    ( or if you got many links inside to perform : give that class to a parent-elment (f.e. color-section) )

    place your galleries on your page (preferably behind your other content on the site.)
    Style them as lightbox galleries!
    those galleries must have now a unique ID (that corresponds with your link ID’s) and a custom class: mfp-hide

    put this to your child-theme functions.php:

    function link_to_gallery_first_item_in_lightbox() {
    ?>
    <script type="text/javascript">
    (function($) {
        $(document).on('click', '.link_to_lightbox a', function(event) { 
            event.preventDefault();
            var linkTarget = $(this).attr('href');
            $(linkTarget).find("a.first_thumb").click();
        });
    })(jQuery);
    </script>
    <?php
    } 
    add_action('wp_footer', 'link_to_gallery_first_item_in_lightbox');
    #1436370

    Hi Guenni007, thank you very much for the details how to achieve this!
    I have it working, however the gallery and button are situated down the page content, and when lightbox opens with first image the screen then scrolls upwards towards the top of the screen. A similar effect to when you use “Back to top” feature, but in the lightbox.
    Could code be adjusted to compensate for this?

    #1436447

    try this first instead:

    function link_to_gallery_first_item_in_lightbox() {
    ?>
    <script type="text/javascript">
    window.addEventListener("DOMContentLoaded", function () { 
    (function($) {
      $('.link_to_lightbox a').addClass('no-scroll');
        $(document).on('click', '.link_to_lightbox a', function(event) { 
            event.preventDefault();
            var linkTarget = $(this).attr('href');
            $(linkTarget).find("a.first_thumb").click();
        });
    })(jQuery);
    }); 
    </script>
    <?php
    } 
    add_action('wp_footer', 'link_to_gallery_first_item_in_lightbox');

    If you have installed a plugin like “Page scroll to id” – then we had to adjust it too.

    #1436483

    This Worked a treat thank you!
    Thank you very much for the helpful support around this.

    #1436538

    Hi,
    Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Open a Gallery (lightbox) from a button or hyperlink’ is closed to new replies.