-
AuthorPosts
-
March 4, 2024 at 6:50 pm #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.March 4, 2024 at 8:55 pm #1436300and 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/
March 4, 2024 at 9:12 pm #1436302Hi , 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.March 4, 2024 at 9:13 pm #1436303PS: 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.
March 4, 2024 at 9:36 pm #1436307the 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-hideput 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');
March 5, 2024 at 1:19 pm #1436370Hi 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?March 6, 2024 at 7:42 am #1436447try 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.
March 6, 2024 at 10:59 am #1436483This Worked a treat thank you!
Thank you very much for the helpful support around this.March 6, 2024 at 8:19 pm #1436538Hi,
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 -
AuthorPosts
- The topic ‘Open a Gallery (lightbox) from a button or hyperlink’ is closed to new replies.