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

lightgallery.js:628 Uncaught Error: Make sure that slide 0 has an image/video src #50

Closed starzou closed 7 years ago

starzou commented 8 years ago
<!-- data-src should not be provided when you use html5 videos -->
<ul id="html5-videos">
  <li data-poster="video-poster1.jpg" data-sub-html="video caption1" data-html="#video1" >
      <img src="img/thumb1.jpg" />
  </li>
  <li data-poster="video-poster2.jpg" data-sub-html="video caption2" data-html="#video2" >
      <img src="img/thumb2.jpg" />
  </li>
</ul>
starzou commented 8 years ago
    Plugin.prototype.isVideo = function (src, index) {

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

data-src should not be provided when you use html5 videos.

So, There is a logic error here. @sachinchoolur

denvist commented 7 years ago

@starzou

You need to use selector: lightGallery(document.getElementById('html5-videos'), {selector: '.item'});

<!-- data-src should not be provided when you use html5 videos --> <ul id="html5-videos"> <li data-poster="video-poster1.jpg" data-sub-html="video caption1" data-html="#video1" > <img src="img/thumb1.jpg" class="item" /> </li> <li data-poster="video-poster2.jpg" data-sub-html="video caption2" data-html="#video2" > <img src="img/thumb2.jpg" class="item" /> </li> </ul>

There is documentation: html-markup

anandmajethiaindia commented 7 years ago

Do we have a solution for this?

sachinchoolur commented 7 years ago

Hey @anandmajethiaindia , Yes, you need to follow any of the HTML markup provided in the demo page- In case, if you are not able to solve the issue please provide a jsfiddle or codepen demo.I'll fix the issue and send you back

dweber019 commented 6 years ago

@sachinchoolur Here a codepen with the issue https://codepen.io/anon/pen/qYMorx

Here a PR which is related https://github.com/sachinchoolur/lightgallery.js/pull/24

And in my opinion the issue https://github.com/sachinchoolur/lightgallery.js/issues/76 is correct.

What do you think?

sachinchoolur commented 6 years ago

Hey @dweber019, The issue has been fixed. Please use the latest version of lightgallery.js

Actually, the pr - https://github.com/sachinchoolur/lightgallery.js/pull/24 created the issue :(

dweber019 commented 6 years ago

@sachinchoolur thanks that fixed the issue. I still have an issue. I changed this https://codepen.io/anon/pen/qYMorx to the simplest setup but still it doesn't work.

Edit: Fixed this above issue by including lg-video.js into my site.

sachinchoolur commented 6 years ago

Here is the working demo - https://codepen.io/sachinchoolur/pen/vjwmYd

balukov commented 5 years ago

There is works for me:

  1. class = item
    <div id="lightgallery">
    <a class="item" href="/img/img.png">
    <img src="/img/img.png" />
    </a>
    </div>
  2. selector: ".item"
    <script>
    $(document).ready(function() {
    $("#lightgallery").lightGallery({
      thumbnail: true,
      download: false,
      selector: ".item"
    });
    });
    </script>