photoswipe-在画廊展示期间添加图像 [英] photoswipe - adding images during gallery show

查看:118
本文介绍了photoswipe-在画廊展示期间添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道使用jquery将图像添加到照片清单很简单,但是我无法弄清楚如何在浏览图库时更新图像列表,即不返回图像列表.我发现的另一种方法(没有jquery,因为它直接将图像添加到photowipe实例中)是使用下面的代码,但是似乎在图库中更新列表的唯一可能性是返回到第一个图像(在进行操作之前)到第一张图片,一切都是一团糟).浏览图库时是否有刷新列表的功能?

I know it's simple to add images to a photoswipe list with jquery, but I can't figure out how to update the image list while browsing the gallery, i.e. without going back to the image list. An alternative (without jquery because it adds images directly to photoswipe instance) I found is to use the code below, but it seems that the only possibility to have the list updated while in the gallery is to go back to the first image (before going to the first image, everything is a mess). Is there any function to refresh the list while browsing the gallery?

for (i = 0; i < fileList.length; i++) { //add new image list
      console.log(fileList[i]);
      instance.cache.images.push(new Code.PhotoSwipe.Image.ImageClass(fileList[i], fileList[i].url, fileList[i].caption, ''));
    };

推荐答案

即使画廊当前处于打开状态,您也可以将图像添加到PhotoSwipe.

You can add images to PhotoSwipe even when gallery is currently open.

这里是文档中的示例(请参见动态添加幻灯片),其中 pswp 是您的PhotoSwipe对象( new PhotoSwipe()返回的内容).

Here is an example from documentation (see chapter Adding slides dynamically) where pswp is your PhotoSwipe object (what new PhotoSwipe() returns).

pswp.items.push({
  src: "path/to/image.jpg", 
  w:1200,
  h:500 
});

它在PhotoSwipe v4.1.1中对我有用

It works for me in PhotoSwipe v4.1.1

这篇关于photoswipe-在画廊展示期间添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆