Support » Plugin: Lightbox 2 » [Plugin: Lightbox 2] "lightbox2 automatically" – how to exclude some images?

  • Hello,
    the plugin works OK in WP3.2.1 and the option ‘Add rel=”lightbox[]” to all linked images’ is very nice. Nevertheless, is there any possibility to EXCLUDE some if linked images in the page/post from this “auto-add” option?

    I tried to add something like rel=”false” to these items manually, but the only result is nonvalid code:
    rel=”false” rel=”lightbox[]”

    It seems the hack have to be done in regular expressions for adding of the lightbox[] string:

    $pattern = “/(<a(?![^>]*?rel=[‘\”]lightbox.*)[^>]*?href=[‘\”][^’\”]+?\.(?:bmp|gif|jpg|jpeg|png)[‘\”][^\>]*)>/i”;
    $replacement = ‘$1 rel=”lightbox[‘.$post->ID.’]”>’;
    $content = preg_replace($pattern, $replacement, $content);

    Do you have any idea?
    Thank yoe very much,
    with best regard, Joo

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Joo-Joo,

    Did you get an answer to this? I need to Auto Lightbox most of my images but not those added to the sidebar widget.



    Hello Chris,
    I am sorry, but I have postponed that (and nobody has put an answer to the forum, surprisingly…). It is really a matter of clever regular expression, because it is applied on the whole content.

    With best regards, Joo

    Hi Joo,

    Thanks for your reply. In my case I was using NextGen Gallery and found that it was NGG that was adding the rel=lightbox code in its template files. I amended the NGG template file for the widget area to not include the lightbox code and now my main galleries use lightbox but the sidebar widget images link through to the main gallery pages which is what I was trying to do.

    Don’t know your exact application but if you’re using something like NGG it might be worth looking at their templates rather than hacking lightbox too much.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Lightbox 2] "lightbox2 automatically" – how to exclude some images?’ is closed to new replies.