【问题标题】:lightgallery markup trouble with justified image grid具有合理图像网格的 lightgallery 标记问题
【发布时间】:2015-12-05 03:15:30
【问题描述】:

您好,我在使用我的 JIG 画廊实现 lightgalley 灯箱时遇到了问题。 JIG 生成的图库代码如下所示:

HTML

<div id="jig2" class="justified-image-grid jig-eec93aceb26f618c747e9fe2abded7ce jig-preset-c1" style="width: 1278px;">
  <div class="jig-imageContainer jig-contentID-ML-1191">
    <div class="jig-overflow" style="opacity: 1; width: 658px; height: 438px;">
      <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1913.jpg">
        <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1913.jpg&amp;h=1040&amp;w=1560&amp;q=45&amp;f=.jpg" width="658" height="439" style="width: 658px; height: 439px; margin-top: 0px;"></a>
      </div>
    </div>
    <div class="jig-imageContainer jig-contentID-ML-1190 jig-last">
      <div class="jig-overflow" style="opacity: 1; width: 614px; height: 438px;">
        <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1912.jpg">
          <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1912.jpg&amp;h=1040&amp;w=1456&amp;q=45&amp;f=.jpg" width="614" height="439" style="width: 614px; height: 439px; margin-top: 0px;"></a>
        </div>
      </div>
      <div class="jig-imageContainer jig-contentID-ML-1192 jig-last">
        <div class="jig-overflow" style="opacity: 1; width: 634px; height: 448px;">
          <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1915.jpg">
            <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1915.jpg&amp;h=1040&amp;w=1472&amp;q=45&amp;f=.jpg" width="634" height="448" style="width: 634px; height: 448px; margin-top: 0px;"></a>
          </div>
        </div>

按照指南 (http://sachinchoolur.github.io/lightGallery/demos/html-markup.html) 我尝试了以下代码但没有成功。当我单击图库项目时,lightgallery 未加载:

JS

<script type="text/javascript">
    $(document).ready(function() {
      $('.justified-image-grid').lightGallery({
        selector: '.lulz'
      });
});
</script>


<script type="text/javascript">
      $('.justified-image-grid').lightGallery({
        selector: '.lulz'
      });
</script>

<script type="text/javascript">
      $('.justified-image-grid').lightGallery();
</script>

<script type="text/javascript">
      $('#jig2').lightGallery();
</script>

我可以加载 lightgallery,但它不会显示具有此 JIG 默认设置的自定义灯箱的图像:

<script type="text/javascript">
          $('#jig2 a.jig-link').lightGallery();
</script>

或在图库中加载单个图像

<script type="text/javascript">
          $('.lulz').lightGallery({
            selector: 'this'
   });
</script>

还可以复制演示作品。我上周让它工作了,但我的编码进度丢失了。所以我知道一定有解决办法,只是找不到了。

【问题讨论】:

标签: jquery html lightbox lightgallery


【解决方案1】:

已解决,我在代码中发现了另一个 lightgallery 标记,我可能忘记删除了。

现在,当用作 jig 的自定义灯箱调用时,此代码可以工作:

$('.justified-image-grid').lightGallery({
selector: '.lulz'
});

$('#jig1').lightGallery({
selector: '.lulz'
});

也可以。但是我它只适用于页面上的第一个画廊,即使在使用时也不会加载后续画廊

$('#jig2').lightGallery({
selector: '.lulz'
});

【讨论】:

    【解决方案2】:
    $(JIG_selector).lightGallery({selector: '.lulz'});
    

    到 JIG 设置 > 灯箱选项卡 > 自定义灯箱 JS 调用。

    【讨论】:

    • 嗨,Firsh,您的时间。这确实是我在按照您的示例后尝试的第一件事,但它似乎与 lightgallery 不兼容,甚至不打开灯箱或显示图像。我找到了一个解决方案(见上面的答案),但现在在这里解决这个问题:stackoverflow.com/questions/34106608/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多