How do I open fancybox via manual call for a gallery in the html not via the jquery options?
This answers the question of opening the gallery manually.
However, what if I want to open a specific image in a gallery? It could be any image in the gallery list. Is there a way to do that?
I have tried this
$("#launcher").on("click", function(){
$(".fancybox.default").eq(0).trigger("click");
});
where I add an additional class “default” for the image I want to show.
but when I run it, it shows that image but doesn’t have next/prev button for gallery.
You have to simulate a click on the element you want to focus.
JQuery lets you do this with the
.clickfunction (link).I took the example an let it focus on element of the group.
The first method uses the same selector, fancybox used to create the group
Alternitvly you can assign an ID to the element you want to focus and simulate a click on it
(id assigned to the thrid a element
and then select the element directly:
BR,
Stefan