WordPress.org

Ready to get started?Download WordPress

Forums

WP jQuery Lightbox
[resolved] Skip lightboxing for one image on an otherwise auto-lightboxed site (7 posts)

  1. SchuminWeb
    Member
    Posted 2 years ago #

    Wikipedia and Wikimedia Commons file description page URLs are formatted as such:

    http://commons.wikimedia.org/wiki/File:Dachshund_drawing.jpg

    These sorts of links are not images, but are description pages. I have my site, at http://falcon.schuminweb.info/ , set to render all image links as lightboxes through the wp-jquery-lightbox plugin. WordPress, with the wp-jquery-lightbox plugin installed and active, calls up the lightbox for this image because of the image extension, and then fails to produce a coherent result because it's not a graphic.

    Is there any sort of tag to place or thing I can do to make wp-jquery-lightbox skip a specific link for lightboxing?

    Thanks!

    http://wordpress.org/extend/plugins/wp-jquery-lightbox/

  2. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    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. ???

  3. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  4. SchuminWeb
    Member
    Posted 2 years ago #

    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!

  5. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  6. Pepperfly
    Member
    Posted 2 years ago #

    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="http://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. :-)

  7. Pepperfly
    Member
    Posted 2 years ago #

    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. ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic