0

我使用 PrettyPhoto Jquery 插件作为 Lightbox 来在我的网站上显示图像,当用户单击缩略图时,图像会出现在叠加 DIV 中。

默认情况下,PrettyPhoto 使用<a>围绕图像的锚链接 ( )。锚点具有指向图像原始大小/更大版本的链接。我不想使用<a>标签,因为我更喜欢这些图像不会被索引并且不会使用nofollow。是否可以选择替换<a>例如并获得相同的结果?

我自己尝试过,但它没有按预期触发带有原始图像的覆盖 div。也许我可以在代码中做一些事情来使它工作。

再次,不要:

 <a href="original-image.jpg"><img src="thumb,jpg /></a>

想要:

 <span data-source="original-image.jpg"><img src="thumb.jpg /></span>

原文件非压缩Jquery插件可以通过这个链接下载

另一个可能不错的选择是保留 anchoe,但使用href="#"原始图像 URL 并将其放在另一个属性中,例如“数据源”并从那里读取它。这甚至是一个更好的选择。

谢谢

4

1 回答 1

1

尝试在插件中更改此行

pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return $(n).attr('href'); }) : $.makeArray($(this).attr('href'));

pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return $(n).attr('data-source'); }) : $.makeArray($(this).attr('data-source'));

编辑:和

set_position = jQuery.inArray($(this).attr('href'), pp_images); // Define where in the array the clicked item is positionned

set_position = jQuery.inArray($(this).attr('data-source'), pp_images); // Define where in the array the clicked item is positionned
于 2012-10-16T12:33:36.730 回答