sachinchoolur / lightgallery.js

Full featured JavaScript image & video gallery. No dependencies
https://sachinchoolur.github.io/lightgallery.js/
Other
5.3k stars 596 forks source link

"isVideo" function will never return "true" for html5? #64

Closed roypardi closed 7 years ago

roypardi commented 7 years ago

In the isVideo() function there is a test for src which throws an error if a src is not provided. Cool. But later there is this:

    if (!src && html) {
        return {
            html5: true
     };

If src is "falsey" then we would never get that far. I'm running into this while trying to sort out why I can't get dynamic html5 video to work with lightgallery.js in an Electron desktop project.

I don't know if the above is a bug or not (not a JS hero...) but changing that to affirmative tests (if src && html) seems to give a correct result.

In context:

Plugin.prototype.isVideo = function(src, index) {

    if(!src) {
        throw new Error("Make sure that slide " + index + " has an image/video src");
    }

    var html;
    if (this.s.dynamic) {
        html = this.s.dynamicEl[index].html;
    } else {
        html = this.items[index].getAttribute('data-html');
    }

    if (!src && html) {
        return {
            html5: true
     };
}

//etc
sachinchoolur commented 7 years ago

Hey @roypardi, At present, lightGallery does not accept src for HTML5 videos. It is managed via data-sub-html attribute. Hope that is clear.

http://sachinchoolur.github.io/lightGallery/demos/html5-videos.html