سؤال

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>

نصائح أخرى

Ideally when rendering your view, you should check if this is noimage.png then don't print.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top