Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1350166

    Hi,
    is it possible to start/access a gallery in the lightbox through a textlink?
    Best regards,
    Vera

    • This topic was modified 2 years, 7 months ago by Vera.
    #1350180

    Hey Vera,
    Please try this solution.

    Best regards,
    Mike

    #1350182

    now – this is my testsetting for you:

    1) The textblock with the links to the galleries got a custom-class: text_to_lightbox
    2) The links of these texts refer to the ID of the correlating gallery. ( in my case it is gallery1 and gallery2)
    3) if you like to hide those galleries – set a custom class to each of them: mfp-hide ( this is a predefined class on enfold to hide those containers )
    4) give a custom ID to the gallery – ( gallery1, gallery2 etc – what you like – only it has to correlate with the links of the texts)
    5) put this to your child-theme functions.php:

    
    function text_link_to_gallery_lightbox() {
    ?>
    <script type="text/javascript">
    (function($) {
        $(document).on('click', '.text_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', 'text_link_to_gallery_lightbox');

    see result here: https://webers-testseite.de/hidden-gallery/#gallery2
    The advantage is that you can style your galleries as enfold alb element – do not forget to set the lightbox link active.

    #1350198

    Hi,
    great. That works perfectly.
    Thanks a lot.
    Best regards,
    Vera

    #1350215

    Hi Vera,

    Great, I’m glad that you got it working. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1350288

    Hi,
    thank you. For my part you can close the topic.
    Best regards,
    Vera

    #1350309

    Hi,
    Thanks for sharing Guenni007, Vera, 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

    ** Update **
    If you find that the lightbox does not start with the first image of the gallery order you can try this script instead:

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

    This is the reasoning behind the change.

    • This reply was modified 2 years, 6 months ago by Mike. Reason: behavior reported in another thread
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘start gallery in lightbox via textlink’ is closed to new replies.