WordPress.org

Ready to get started?Download WordPress

Forums

Lightbox 2
"lightbox2 automatically" - how to exclude some images? (4 posts)

  1. joo-joo
    Member
    Posted 2 years ago #

    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

    http://wordpress.org/extend/plugins/lightbox-2/

  2. cehwitham
    Member
    Posted 2 years ago #

    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.

    Thanks

    Chris

  3. joo-joo
    Member
    Posted 2 years ago #

    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

  4. cehwitham
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags