Disable auto-lightboxing per post -WordPress

I’m using the Lightbox 2.9.2 (Rupert Morris, based on ) on my WordPress blog (designink.nl) and use the auto-lightbox setting (lets the plugin add html to image links). However, i’d like to prevent a specific image on a post to be called by lightbox. Is there a code to break/prevent this on individual instance and not change my automatic-setting?

Related posts

Leave a Reply

2 comments

  1. go into lightbox2.php, and change the following function:

    function autoexpand_rel_wlightbox ($content) {
        global $post;
        if (strpos($content,"<!-- nolightbox -->") == 0) {
            $pattern        = "/(<a(?![^>]*?rel=['"]lightbox.*)[^>]*?href=['"][^'"]+?.(?:bmp|gif|jpg|jpeg|png)['"][^>]*)>/i";
            $replacement    = '$1 rel="lightbox['.$post->ID.']">';
            $content = preg_replace($pattern, $replacement, $content);
            return $content;
        } else {
            return $content;
        }
    }
    

    Added – looks for and if it sees it, keeps all links on the page as original 🙂

  2. I haven’t had a chance to try this out, but you could try printing this bit of jQuery in the header of your website:

    var no_light_box = jQuery("img[src$='THE_IMAGE_PATH']"); //Specify your image
    jQuery(no_light_box).attr({ rel: "" }); //Reset the rel value
    

    Essentially you’re going to find the image path of the image you do not want to have light box and then reset it’s rel attribute from lightbox[26] (this seems standard in that plugin to nothing, so it will not initiate a lightbox when clicked.

    It would probably be easier and more manageable if you implemented your own lightbox code.