dimsemenov / photoswipe-dynamic-caption-plugin

A dynamic caption plugin for PhotoSwipe v5. Automatically positions the caption aside or below the image.
MIT License
65 stars 12 forks source link

Allow custom captions on data source #10

Closed dealancer closed 2 years ago

dealancer commented 2 years ago

Is there a way this plugin can be used when using data source? See https://photoswipe.com/data-sources/. If so please provide an example.

It looks like this plugin requres PhotoSwipeLighbox object, but we also make it run for PhotoSwipe one?

dimsemenov commented 2 years ago

yes, you may use captionContent option

captionContent: (slide) => {
  console.log(slide.data);
  return slide.data.myCaption;
}

assuming slide data is something like:

{
  src: 'image.jpg',
  width: 300,
  height: 300,
  myCaption: 'caption text'
}

It looks like this plugin requres PhotoSwipeLighbox object, but we also make it run for PhotoSwipe one?

For now - no, but I'll probably allow it in future versions, feel free to submit pr too.

dealancer commented 2 years ago

Thanks!