2

i am building webside with photoswipe, it nice and has deeplinking kind of implementation, but the only problem with this pid gid implementation is that if someone link your photo somewhere using hash and you will remove that photo from your gallery, the linkt will point to another photo that gets the same pid / index in gallery...

pid on website always gets values 1,2,3,4,5,6,7,8

i am trying to somehow force photoswipe to take pid from some attribute, or at least parse it before with some mapping from custom value to real image index, but i kind of failing...

anyone tried such kind of implementation and succeeded ?

thx in advance

altair13
  • 21
  • 4

2 Answers2

0

You can check out the options documentation

Taken from that page, below excerpt shows how to customize url, text, image_url and raw_image_url properties. (You just have to override the getter methods.)

// 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 || '';
},
aug70co
  • 3,965
  • 5
  • 30
  • 44
0

Actually since version a v4.0.8 photoswipe supports custom pid

altair13
  • 21
  • 4