-
AuthorPosts
-
May 2, 2022 at 11:13 am #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, 6 months ago by Vera.
May 2, 2022 at 1:09 pm #1350180Hey Vera,
Please try this solution.Best regards,
MikeMay 2, 2022 at 1:34 pm #1350182now – 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.May 2, 2022 at 4:04 pm #1350198Hi,
great. That works perfectly.
Thanks a lot.
Best regards,
VeraMay 2, 2022 at 5:36 pm #1350215Hi 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,
RikardMay 3, 2022 at 11:52 am #1350288Hi,
thank you. For my part you can close the topic.
Best regards,
VeraMay 3, 2022 at 12:46 pm #1350309Hi,
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, 5 months ago by Mike. Reason: behavior reported in another thread
-
AuthorPosts
- The topic ‘start gallery in lightbox via textlink’ is closed to new replies.