Please add the ability to link an ACF gallery from a link. Currently, there are only the options Lightbox Image
and Lightbox Video
… please add Lightbox Gallery
(as we are opening the gallery through a link it starts with the first image).
My Workaround currently is to add a hidden gallery and have the link on a URL triggering javascript:openGallery()
… that function is added by me in header scripts and uses a querySelector
to find the gallery and click
on the first image using JavaScript.
Update: one can also use javascript:document.querySelector('.myGallery li div').click()
with myGallery
being a class I assigned to my hidden gallery (no need for custom code). Would still like a more elegant solution, though.
2 Likes
I want to do exactly that - open a gallery in lightbox mode when users click a “More photos” button. Lightbox Gallery
would be the solution.
However, I do not fully understand your workaround, how do you run the javascript code on button click?
1 Like
So, using a bricks gallery block, we hide the gallery with the following CSS:
%root% {
display: none;
}
Then we give it a class, for example, GuestRoomGallery
(or whatever) in the style tab under “CSS”
Then we add a button somewhere else on the page to open the gallery in lightbox mode. This is the JS code that needs to go on the button
javascript:document.querySelector('.GuestRoomGallery li figure a').click()
Notes:
- Make sure to use the same CSS class name as before in the JS code. In this example, I’ve used
GuestRoomGallery
- The button should be set to “external link”. Then paste the JavaScript code into the URL field
Tested with Bricks 1.9.7.1
1 Like