Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1486794

    Hi

    I have a page which loads a lightbox gallery when you click on the image/icon of the image.
    I have a button underneath which I want to launch the same lightbox gallery if you click on it.
    I can’t see any custom url associated with the lightbox gallery.
    Is there any way I can create the actioin on the button that launches the gallery?

    Please advise.

    #1486848

    Hey woogie07,

    Thank you for the inquiry.

    Have you tried using an image URL as the link for the Button element? This should trigger the lightbox and open the gallery that includes the images on the page. Let us know if this works for you.

    Best regards,
    Ismael

    #1486922

    Hi

    If I put the url first image of the lightbox in, only that image loads and not the lightbox gallery.

    Please advise.

    Thanks
    Marcus

    #1486959

    Hi,

    Thank you for the update.

    This is still possible, but we need to create a custom script to trigger the gallery when the button is clicked. To start, try to edit the gallery, go to Advanced > Developer Settings, and apply “ff-gallery-1” in the Custom CSS Class field. Next, edit the button element and place “#ff-gallery-1” in the link field. After that, add this code to the functions.php file.

    add_action('wp_footer', function() { ?>
        <script>
            jQuery(document).ready(function($) {
                $('a[href^="#ff-gallery-"]').on('click', function(e) {
                    e.preventDefault();
                    var target = $(this).attr('href').replace('#', '');
                    $('.' + target + ' .avia-gallery-big').trigger('click');
                });
            });
        </script>
    <?php });
    

    You can do the same for the second and third gallery, just replace -1 with -2 and -3.

    Best regards,
    Ismael

    #1486969

    Hi

    Thanks for that. I will try it.

    Can the script go in the CSS, or can it be added to Code snippets plugin that we run on the site?

    Thanks

    #1486991

    Hi,

    Please paste it as a PHP snippet in your plugin, or add it to functions.php in your child theme.

    Best regards,
    Rikard

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