• I use lightbox only for single images (one image per post). I don’t need (in fact, I don’t even want to have) any navigation. But after the latest update of plugin, lightbox started displaying navigation bar and next/previous buttons. I use prettyPhoto script. I tried to change options which could be connected (even, if previously everything was all right) but it is still the same. Is there any way to disable it, and restore functionality from previous version? Or to downgrade plugin?

    https://www.ads-software.com/plugins/responsive-lightbox/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I might be wrong but i notice the nav bar/next/prev buttons are the result of the prettyPhoto.js file which this plugin is more a wrapper around some other person’s work. Not sure if this javascript file was updated and doesnt check for your condition (1 image per post). I checked the js file and it looks relatively easy to fix the problem.

    The problem is because this plugin is putting in a “-” even for non-galleries for the data-rel attribute. Doing so confuses prettyPhoto.js file into thinking both are galleries and hence enables nav bars even for 1 photo.

    The fix is easy. One can either change the jquery.prettyphoto.js file (line 149) from:

    galleryRegExp = /\-(?:.*)/;
    to
    galleryRegExp = /\gallery(?:.*)/;

    Or this plugin can simply just stop using “-” for single images (non-galleries). It’s used for non-galleries to # each image in a post e.g. lightbox-1, lightbox-2,….lightbox-n, where n is the total # of images in a post. Not sure why this is necessary unless the author is making it universal so it works across the other scripts (essentially you only need to have a data-rel=”lightbox” not data-rel=”lightbox-1″..) So if u have 1 image it is called: lightbox-1. Because of this “-” prettyPhoto then thinks it is a gallery and hence shows the nav bar.

    Alternatively, if you dont want to touch the author’s plugin php file nor the prettyPhoto.js file you can add a wordpress filter that looks for “lightbox-[0-9]+” and replace it with “lightbox”, stripping the “-” from the content before it is sent out to the browser. At least that way if this plugin updates your changes will still work. For example (this should work and still allow galleries to work too):

    function my_the_content_filter($content)
    {
         $content = preg_replace('/lightbox-[0-9]+/i','lightbox',$content);
         return $content;
    }
    add_filter( 'the_content', 'my_the_content_filter',99 );

    Cheers
    Kimberly

    ^^–oops forgot to mention..if you go with the 3rd option (my sample code) you simply add this into your functions.php file (found in your theme’s folder). Sorry, just noticed i forgot to mention that (and this site doesnt allow me to edit what i wrote).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Single image now working like gallery’ is closed to new replies.