Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic-caption-plugin not working with videos #1

Open
acwolff opened this issue Aug 18, 2021 · 3 comments
Open

Dynamic-caption-plugin not working with videos #1

acwolff opened this issue Aug 18, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@acwolff
Copy link

acwolff commented Aug 18, 2021

I use both images and videos:

<div id="gallery" class="thumbs-jg thumbsgallery" >

<a  href= "slides/IMG_0877.mp4" data-pswp-is-video="true" data-pswp-is-poster="slides/IMG_0877.jpg"
data-pswp-width="608" data-pswp-height="1080"  id="0"  data-caption=''>
<img src="slides/IMG_0877.jpg" class="video"  width="90" height="160"  alt="2013-05-06" title="2013-05-06" />
</a>

<a  href= "slides/170814-133529_Erfgoedroute.jpg" data-pswp-width="1584" data-pswp-height="1080"  id="1"
data-caption='etc'

And use the dynamic-caption-plugin:

const captionPlugin = new PhotoSwipeDynamicCaption(lightbox, {
    type: 'auto',
    captionContent: (slide) => {
        return slide.data.element.dataset.caption;
    }
});
lightbox.init();

If you open the Light box by clicking on the first video thumbnail in this album with this code, you get a crash:

VM8 index.htm:683 Uncaught (in promise) TypeError: Cannot read property 'dataset' of undefined
at PhotoSwipeDynamicCaption.captionContent (VM8 index.htm:683)
at PhotoSwipeDynamicCaption.getCaptionHTML (photoswipe-dynamic-caption-plugin.esm.js:331)
at PhotoSwipeDynamicCaption.updateCaptionHTML (photoswipe-dynamic-caption-plugin.esm.js:353)
at PhotoSwipe. (photoswipe-dynamic-caption-plugin.esm.js:60)
at photoswipe.esm.js:3703
at Array.forEach ()
at PhotoSwipe.dispatch (photoswipe.esm.js:3702)
at PhotoSwipe.init (photoswipe.esm.js:4345)
at PhotoSwipeLightbox._openPhotoswipe (photoswipe-lightbox.esm.js:633)
at photoswipe-lightbox.esm.js:590

To prevent this, I use this code:

    captionContent: (slide) => {
        try {
            return slide.data.element.dataset.caption;
        }
        catch(err) {
            return null; //'',   false or null;
        }

    }

What is the best value to return in the catch(err) code?
Any chance this will be resolved, so that I can add captions to video's?

@dimsemenov dimsemenov added the bug Something isn't working label Aug 27, 2021
@acwolff
Copy link
Author

acwolff commented Mar 14, 2022

When is the next update?

@acwolff
Copy link
Author

acwolff commented Dec 28, 2023

Any progress with the solution of this bug?

@acwolff
Copy link
Author

acwolff commented Dec 30, 2023

See also at the end of this issue:
dimsemenov/PhotoSwipe#2084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants