Viewing 6 replies - 1 through 6 (of 6 total)
  • This is a great feature request, and one I’m not sure of how to solve well.

    There are lots of sites with creative prettylinks ending in .jpg (or some other image format) but serving you a html-page. ZenPhoto galleries does this, for instance.

    WP jQuery Lightbox can never know what URL points to a real image file and which will be translated to something else by the server.

    Help me figure out a robust solution. Some suggestions from the top of my head:

    1. I add a settings field where you could enter domains which should never be lightboxed.

    2. I add support for a “blocking” rel-attribute: instead of leaving it empty or adding rel=”lightbox”, we could add rel=”nobox” or somesuch

    3. Add an option to never lightbox off-site links. All cases of “image-url-not-serving-an-image” has been content served from external domains. And hotlinking is rude anyway.

    4. ???

    Come to think of it; you should try and just add a bogus rel-attribute. My lightbox-script is supposed not to clobber pre-existing attributes, so an anchor with rel="whatever" should be left alone. Let me know how that works out.

    Thread Starter SchuminWeb

    (@schuminweb)

    Your last suggestion of just putting in a bogus rel-attribute worked like a charm. Thank you very much.

    As far as features go, I like #1 in your earlier comment, where you add a settings field to blacklist or whitelist certain domains for lightboxing. I think optimally, there should be a setting to have either a whitelist of domains (i.e. only these domains should be lightboxed and nothing else) or a blacklist of domains (i.e. all domains should be lightboxed except for these), and then a text box for the corresponding list. That seems like the best solution, since while the bogus rel-attribute definitely works, it is a little cumbersome, and too easy to forget to set and/or do inconsistently.

    Let me know what you think!

    I just released version 1.3.4. Unfortunately I couldn’t figure out any way to do white- or blacklisting without making the filter a lot more complicated.

    Added some info to the docs about bogus rel-attributes though, hoping that’ll help someone.

    And of course, you can always write your own the_content filter to automatically disable lightbox for problematic domains.

    Not hijacking, just trying to see if I can help provide ideas for a solution.

    I’m experiencing a similar problem, where when I add the following markup…

    <a href="https://www.mydomain.com/download.php?file=path/to/filename.jpg">Download Image</a>

    …the anchor link is grep’d and sees “filename.jpg.” which looks like an apparent image file to the plugin, so automatically adds class=”lightview” in the source, and thus the image will open in a lightbox.

    In this case, I don’t want to open the image in a lightbox. I’m trying to force a download instead. Interestingly, if I do open the image in a lightbox and I’ve added marked up text, I can download the file (it doesn’t open in another lightbox). I can force download non-image file types fine. This is only a problem for image file types. Basically, for my purposes the class shouldn’t be added when “download.php?file=” is in the anchor link.

    That may be easy enough to modify the filter in this case, but rather than doing it selectively for my case, how about adding a pre-filter that says (pseudo) “skip this one… it has a rel=”no-lightbox” attribute in the anchor tag … or something like that?

    Obviously that means the user will have to add that rel attribute (as needed), but the plugin will know to check for that pattern first, skip it if it’s there, otherwise do business as usual. Presto?

    If I knew how to do this, I’d do it myself. But I’m not a coder. ?? However, I can see this is the grep pattern where the real magic happens (I just don’t know how to modify it):
    $pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)\?{0,1}\S{0,}['\"][^\>]*)>/i";

    Thanks for considering. ??

    I guess I didn’t read everything close enough, particularly adding a bogus rel attribute. Hrmmm… well… at least I was in the ballpark with a fair idea. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: WP jQuery Lightbox] Skip lightboxing for one image on an otherwise auto-lightboxed site’ is closed to new replies.