简体   繁体   English

如何在灯箱中隐藏特定图像

[英]how to hide specific image in lightbox

i have images which open in light box but i want when noimage.png is available to view in light box it should not be displayed in view of light box 我有在灯箱中打开的图像,但我希望当noimage.png可以在灯箱中查看时,不应在灯箱视图中显示

here is a link of my website please open the last thumbnails and view next image to understand.. Click here script that i am using for lightbox 这是我网站的链接,请打开最后的缩略图并查看下一张图片以了解。. 单击此处 我用于灯箱的脚本

<script type="text/javascript" src="LightBox/js/jquery.js"></script>
        <script type="text/javascript" src="LightBox/js/jquery.lightbox-0.5.js"></script>



        <script type="text/javascript">
            $(function() {
                $('#gallery a').lightBox(
{ overlayOpacity: 0.6,
    imageLoading: 'LightBox/images/lightbox-ico-loading.gif',
    imageBtnClose: 'LightBox/images/lightbox-btn-close.gif',
    imageBtnPrev: 'LightBox/images/lightbox-btn-prev.gif',
    imageBtnNext: 'LightBox/images/lightbox-btn-next.gif',
    fixedNavigation: true,
    txtImage: 'Image',
    txtOf: 'of'

});      
  });

  </script>

i have tried to achieve this task 我试图完成这项任务

<script type="text/javascript">
       function pageLoad() {
           if ($("#gallery a[href$='noimage.png']")) {
               $("#gallery a[href$='noimage.png'] img").removeAttr("src");

               $("#gallery a[href$='noimage.png']").remove("#gallery img");

           }
       };

  </script>

is this possible to hide a specific image in light box and it should not be displayed in lightbox popup view 是否可以在灯箱中隐藏特定图像,并且不应在灯箱弹出视图中显示该图像

You could use a class to mark the images to exclude in your lightbox, and those images will not be used in the lightbox. 您可以使用一个类来标记要在灯箱中排除的图像,而这些图像将不会在灯箱中使用。

To mark your images and then initialize the lightbox with this selector 标记图像,然后使用此选择器初始化灯箱

<script type="text/javascript">
    $(function() {
        // Mark unwanted images
        jQuery('#gallery a[href*="noimage.png"]').addClass("no-lightbox");

        // Initialize lightbox without them
        jQuery('#gallery a:not(.no-lightbox)').lightBox({ 
            overlayOpacity: 0.6,
            imageLoading: 'LightBox/images/lightbox-ico-loading.gif',
            imageBtnClose: 'LightBox/images/lightbox-btn-close.gif',
            imageBtnPrev: 'LightBox/images/lightbox-btn-prev.gif',
            imageBtnNext: 'LightBox/images/lightbox-btn-next.gif',
            fixedNavigation: true,
            txtImage: 'Image',
            txtOf: 'of'
        });      
    });
</script>

理想情况下,渲染视图时,应检查是否为noimage.png然后再不打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM