nanogallery2: 当点击缩略图时,是否可以转到一个链接而不是打开灯箱?

问题描述 投票:0回答:1

我使用的是[nanogallery2][1]。我把一些项目动态地添加到我的图库中(通过使用这个示例。https:/codepen.ioKris-BpenwJKowg。). 我知道,通过设置选项 thumbnailOpenImage: false 我们可以在点击缩略图时禁止显示灯箱。能否为图库中的项目设置一个链接,当用户点击缩略图时,将其发送到该链接?

javascript gallery nanogallery
1个回答
0
投票

你可以用属性定义一个自定义的URL destinationURL.

从提到的Codepen,这里有一个例子。

  ...
  // create the new item
  var ID = ngy2data.items.length + 1;
  var albumID = '0';
  var newItem = NGY2Item.New(instance, 'new berlin ' + ID, '', ID, albumID, 'image', '' );

  // define thumbnail -> image displayed in the gallery
  newItem.thumbSet( baseURL + 'berlin2t.jpg', 135, 204); // w,h

  // define URL of the media to display in lightbox
  newItem.setMediaURL( baseURL + 'berlin2.jpg', 'img');

  // DEFINE YOUR SPECIFIC URL
  newItem.destinationURL = "[CUSTOM_URL]";

  ...

不需要禁用 thumbnailOpenImage 选项。

替代解决方案。

使用 fnThumbnailOpen 回调。

这里有一个例子,展示了如何用Fancybox替换内部灯箱。https:/codepen.ioKris-BpenzZNMJj。

© www.soinside.com 2019 - 2024. All rights reserved.