dimsemenov / photoswipe-dynamic-caption-plugin

A dynamic caption plugin for PhotoSwipe v5. Automatically positions the caption aside or below the image.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow custom captions on data source

dealancer opened this issue · comments

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?

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.

Thanks!