我正在使用photoswipe构建网站,它很好并且具有深层链接的实现方式,但这个pid gid实现的唯一问题是如果有人使用哈希链接你的照片,你将从你的图库中删除该照片,链接将指向另一张在图库中获得相同pid /索引的照片...
网站上的pid始终获得值1,2,3,4,5,6,7,8
我试图以某种方式强制photoswipe从某些属性中获取pid,或者至少在使用自定义值到真实图像索引的映射之前解析它,但我有点失败......
有人试过这样的实现并成功吗?
事先提前答案 0 :(得分:0)
摘自该页面,下面的摘录显示了如何自定义 url , text , image_url 和 raw_image_url 属性。 (你只需要覆盖getter方法。)
// Share buttons
//
// Available variables for URL:
// {{url}} - url to current page
// {{text}} - title
// {{image_url}} - encoded image url
// {{raw_image_url}} - raw image url
shareButtons: [
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
{id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
{id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}'},
{id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
],
// Next 3 functions return data for share links
//
// functions are triggered after click on button that opens share modal,
// which means that data should be about current (active) slide
getImageURLForShare: function( shareButtonData ) {
// `shareButtonData` - object from shareButtons array
//
// `pswp` is the gallery instance object,
// you should define it by yourself
//
return pswp.currItem.src || '';
},
getPageURLForShare: function( shareButtonData ) {
return window.location.href;
},
getTextForShare: function( shareButtonData ) {
return pswp.currItem.title || '';
},
答案 1 :(得分:0)
实际上,因为版本a v4.0.8 photoswipe支持自定义pid