简体   繁体   中英

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

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然后再不打印。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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