i am trying to attach images to Photoswipe dynamically.
$('#imgholder').on('tap', function(event){
(function(window,PhotoSwipe){ var options = {
preventHide: true,
getImageSource: function(obj){
return obj.url;
},
getImageCaption: function(obj){
return obj.caption;
}
},
function(){
for (var i = 0; i < images.length-1; i++)
{
instance = PhotoSwipe.attach([{url:images[i]}],options);
}
}
instance.show(0);
}(window,window.Code.PhotoSwipe));
});
I' am trying to avoid the Gallery Tag because i dont want to show the gallery overview. My urls are stored in a simple array.
var images = result.news[index].bilder_url.split("-,-");
Is it possible to attach this array to photoswipe or run a simple for loop? Or is there a different approach?
Thx in advance :)
(function(window, PhotoSwipe){
var
options = {},
instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options);
instance.show(1);
}(window, window.Code.PhotoSwipe));
Thats doing the trick :)
Found in the examples provided by PhotoSwipe.