Lightbox 2.9.2 plugin for Wordpress
Update: Now handles correct image resizing for smaller screens (optional, off by default).
Features spiffy new auto-lightboxing code courtesy of the talented Michael Tyson.
Please read the Frequently Asked Questions included with the plugin before posting a comment!
Get the latest version here . Click a thumbnail pic to see it in action. Learn more about this plugin.
Lightbox 2 allows you to present images in a slick window, while darkening the rest of the page. It makes your site look professional, and adds little to page load times. It does not require any browser plugins to work, and works on just about every web browser out there! When a browser doesn’t support javascript, your web site still looks and works fine.
The brilliant Lightbox 2.2 javascript/css was written by Lokesh Dhakar . I simply made it into a Wordpress plugin and added some options. I’ve had help along the way from several others… thank you, your help is much appreciated!
To install: Put the lightbox-2 folder in your Wordpress plugins folder, then activate it in Wordpress.
Implementing Lightbox is automatic . Create a link to an image to see Lightbox-2 work.
Features:
- Resizes large images to fit the viewer’s screen.
- Auto-lightboxing of all links to images in your posts. No more manually adding rel= to your links! This can be turned off in Lightbox 2 admin options. Also, no double rel= tags.
- Grabs the title from the img title or the img alt if there is no anchor title.
- Themes that determine the colours of the lightbox window. You can select from Black, White or Grey.
- No longer conflicts with any Wordpress themes! This means it looks right, every time. Almost. Unless you are using a theme called stimuli_lightbox… ;)
- Uses wp_enqueue_script to prevent multiple prototype and scriptaculous libraries from clobbering each other. At least with other plugins that use wp_enqueue_script.
- This version works when wordpress is installed in non-standard locations , ie: /wordpress/ instead of /, whereas other Lightbox plugins break.
- Uses the arrow keys as well as P and N keys to navigate between images. The X and Escape keys close the Lightbox window, as does clicking anywhere outside the image.
- Minor cosmetic changes from the scripts by Lokesh.
YES, I will be adding WP 2.5+ ‘gallery’ lightboxing functionality in the future… not very soon, however! So try this plugin in the meantime!
Please read the Frequently Asked Questions included with the plugin before posting a comment!
About this entry
You’re currently reading “Lightbox 2.9.2 plugin for Wordpress,” an entry on stimuli.ca
- Published:
- 02.07.10 / 11am
- Category:
- Software



I do not want this plugin to resize to the browser height or width. Everything worked like I wanted it to, full 100% resize. After updating today it resizes to browser window. How do I make it resize to full 100% size.
Hello!
This plugin seems to mess with certain tags – the output from my plugin, flickrpress, for example:
<a href="http://farm5.static.flickr.com/4039/4337325635_0ecca22f1a.jpg" class="thickbox" rel="lightbox[flickr]"
title="Douz animal market | <a href="http://www.flickr.com/photos/michael-tyson/4337325635">View at Flickr</a>">
I took a look into the Lightbox 2 plugin – the regex that performs the replacement is actually a tad clumsy and inflexible, hence the tag mangling.
The following will do the trick; I’ve tested it on my site and it now works properly. It uses a negative lookahead to avoid performing replacement on tags with the lightbox “rel” value already, instead of performing the change, then ‘fixing’ it, which is what the prior regex was doing, mangling the tag in the process:
function autoexpand_rel_wlightbox ($content) {
global $post;
$pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"] ?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
$replacement = ‘$1 rel="lightbox['.$post->ID.']">’;
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
Hi, Michael.
Sorry, but I am not technical. In which lightbox 2 file do I place this?
* lightbox-2/lightbox2.php
* lightbox-2/options.php
* lightbox-2/readme.txt
* lightbox-2/lightbox.js
And where in the code?
Thank you for your help.
Hello Michael!
First, thanks for your plugin. I have been using it for quite sometime.
My question is along the lines of Shell’s: How to stop it from resizing images? I really liked it when it didn’t do that, and besides, it’s not resizing the images proportionally to the original image’s aspect ratio, distorting them in the process.
Thanks for your help.
Alexandre
Brazil
I’ll see if I can make it optional.
Rupert, that would be ideal. Thanks for your attention to this.
Hi Rupert, I am working on using your Lightbox 2 plugin with my WP-ImageFlow2 plugin. The problem I have is your start function requires the imagelink to have a childnode, if not the script hangs infinitely. Is it possible for you to test for the presence of childnode before doing the title search?
Shell! You are so right! That is *exactly* why I came here. Everything was working perfectly until I updated, and now it is resizing images, which I don’t want it to do. Please, Rupert, if you can, make that optional. Otherwise I love this plugin, it is phenomenal!
I’ve added Michael’s regex, made resizing large images optional (see Settings->Lightbox 2) and I forget what else.
Thank you, thank you, thank you. It works perfectly once again. Where can I donate some money for this plugin. I owe you for this.
Rupert thanks for the great plugin –
If there is any chance to make the resizing happen proportionally? As some others have mentioned it seems to stretch. I for one would love this feature.
Thanks again for great work.
I wanted to point out that I just upgraded from 2.8.2 and there is a conflict with these scripts that allow the navigation to animate using jquery. The prior version worked fine with these scripts so now I can’t use the plugin.
Does anyone know what in this new version is breaking the jquery navigation from working properly?
Any insight would be greatly appreciated. Thank you in advance if anyone can help.
http://www.martysgrill.com/home
First of all thank you!
Question: does it add itself to the posts or pages where I already have added images?
Since the update, Lightbox seems to be having trouble with photobucket links now. Before, it either loaded them correctly or allowed the user to go fullscreen without the thickbox. Now it just leaves the user stuck on the “loading” screen.
I agree with the above post regarding the auto-resize. It’s not keeping the aspect ratio the same, so it’s not as useful for my site.
As well, selecting auto-lightboxing doesn’t seem to do anything to my image links. I’m pretty sure there’s nothing in my Wordpress theme that would be messing with the rel parameter either. Any thoughts?
This is one of the pages where clicking on the pics leaves the user with a loading box: http://frp.unlimited2.net/sw-a-new-skope/
It worked correctly in version 2.8.2 and 2.9.
Wander, You are linking to a photobucket page, not an image.
image: http://img.photobucket.com/albums/v169/cmdrkoenig67/han_solo.jpg
page: http://smg.photobucket.com/albums/v169/cmdrkoenig67/?action=view¤t=han_solo.jpg
OK, images resize without stretching. I also fixed some other stuff. Phew. I’m burnt out!
I am trying to get this plugin working with my theme. I searched the default & classic themes header.php files for ‘wp_header()’ and I was unable to find any reference to them. Is there an updated guide on how to get this working with my own theme? My theme was copied from the default theme and modified.
Thank you so much Rupert for this new update. It is so much appreciated!
Hi,
I am having a trouble when I am using both wordpress and ecommerce plugin. When I use the lightbox it does not want to disappear when clicking on ‘close’ it does, however, close when I press ‘Escape’ on the keyboard?
This is very strange and I do not understand why keyboard works and clicking on close doesn’t. Can someone help please. Here’s a page where the problem occurs:
http://n-ll.co.uk/products/copy_of_3X-Ginseng.html
your awesome
Hello,
I am having issues with some portrait style photos. The plugin works amazingly for all landscape photos, and some portrait photos, but other portrait photos looked squished and scrunched. Is there a way to fix this?
Thank you,
Jim
I do not know if this will help at all but a Portuguese website got around the problem I am having. The URL is http://www.raulnunes.com/. All of his images are resized correctly using lightbox
Okaaay well I see the update for the plug-in fixed this issue.
Sorry for bothering you!
The plug-in is amazing so thank you very much!!
I don’t really want the previous and next function. Just want people to be able to zoom in on selected image.
I could “break” it by removing the prev and next images, even in CSS, but that seems clumsy
It would be a good option.
Meanwhile, any suggestions on how?
I was having trouble with this plugin – the lightbox wouldn’t appear and I got a link to plain page with the photo. As you advised I tried disabling and re-enabling my other plugins and found that it was Image Rotator Pro (it was in my header) that was screwing it up. Just in case that helps anyone..
Thanks for the great plugin, it looks very smooth :-)
Hi thanks for the plugin and making things automatic. I have problems with the latest update. Doesn’t seem to work anymore.
I deactivated and reactivated and nothing seems to work. The only plugin that might have a conflict is Nextgen Gallery, but your plugin was working fine before the last update.
Any ideas on what could be going on? I looked at my header based on the tip that Georgie did, but my header did not have that Image Rotator Pro code.
Hi. I’m having problems with the plugin.
The old version didn’t work and with the update suddenly it worked. But now, it only works for my old pictures on the site, not the new pictures I added today to a post.
For some pictures in that post it will go straight to the full size picture and for others it will tone out, give you a black screen and then jump over to the full size.
Any ideas what the problem is? I have used it both with and without the plugin called “faster image insert”, but I used that plugin with both posts and one is working, the other not, so I don’t know what can be the cause.
I have tried deactivating it and activating it again and I have deactivated all the other plugins too. No luck.
Hi,
I have a new WordPress installation and the plugin does not seem to work with 2 new themes I bought. I read all documentation I found available from your site and the plugin but it is not clear what I need to do to resolve the conflict.
You mention in one place that themes can magle some image properties and I have to hack some CSS – what am I looking for? At the top of this page though you mention that the plugin is supposed to not conflict with virtually any theme. So not sure why is it not working…
Basically I get two images popup. It works properly with the two default WordPress themes but it fails in the same way with 2 new premium themes that otherwise seem to behave very nice.
For clarity, I set up anotehr new WordPress installation just to demonstrate this and using a theme does shows exact same behavior – http://voraciousminds.com/
Are you taking donations? This plugin is excellent. I’d love to send you a few bucks to promote further development and support!
My PhotoBlog Chayacitra looks MUCH better now =)
Hello, I am a new WordPress user.
I installed the newest version of WordPress (2.9.2) onto my host earlier today, and got my website setup…
The issue I am having is that Lightbox is not working.
I have tried my current them, and the default wordpress theme, and it still dosent work.
I have tested in IE and FF with the same results.
I get this error message when the images try to load:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.4; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Timestamp: Tue, 16 Feb 2010 12:04:28 UTC
Message: ’style’ is null or not an object
Line: 33
Char: 6
Code: 0
URI: http://danieldare.com/main/wp-content/plugins/lightbox-2/lightbox-resize.js?ver=1.8
Message: Object doesn’t support this property or method
Line: 3938
Char: 9
Code: 0
URI: http://danieldare.com/main/wp-includes/js/prototype.js?ver=1.6
If I am reading this right, does that mean that the latest version of wordpress dosent work with this plugin?
If it is a fix you cn address, please do asap! I would LOVE to be able to utilize this app :)
-Daniel Dare
Thanks, Tim!
I purposely don’t include paypal nags in lightbox. You are the second person to actually seek me out (Shell, above, was the first) and offer a contribution. That’s really quite remarkable.
Anyway, if you’d care to donate, my palpal ID is stimulusresponse@hotmail.com
Music is the main thing I buy, so you’d be feeding my love for Beatport tracks. I’m in India for a third year in a row and really miss my sweet, sweet electronic music.
Dan: you have what is known as ‘jQuery/Protype conflict’ and it has nothing to do with my plugin.
Just wanted to say thanks for answering my question and you are right – the themes had already lightbox installed though not triggered properly.BTW – your plugin is great!
call me dumb but I can’t find where to change the theme for the plugin from black to white or gray… said Wordpress options.. I dont see them. :(
Hi,
I’ve read all faq and so on and can’t find my problem here. Well then I installed Lightbox for Wordpress and it works fine.
But I got a white line at the bottom of every picture.. really anoying.. some help?!
Hi,
I discovered that the plugin isn’t working anymore on my blog. Before it worked all well. but i have nothing changed inside the settings or database. more people having this problem?
i am using the theme: Aras theme (which worked before with lightbox2)
Thank you for this plugin !
I am having a problem out of the clear blue-
all of the sudden my lightbox 2 will no longer display images, except for the posts where I only have 1 image linked. I have updated to the newest WP and lightbox 2 versions-
everything worked fine before but now it will not display my images in lightbox if more than 1 image is linked.
http://frederickheidbrink.com/blog
please help, love the plugin !
-FRH
Fred: your jQuery line you added to lightbox.js is breaking the javascript. Please remove it.
Great plugin, I really like the look that it adds to my Lazyest gallery. I noticed one small problem when using Lightbox 2.9.2 with Lazyest Gallery 0.15.6.1 but I don’t know which plugin is causing it. If the images in a folder span multiple pages, the Lightbox view doesn’t work for the images in that folder. I’ve worked around it by switching off pagination but thought you might like to know about it.
I really love this one and use it on my site http://www.devogelman.com
I have a question though. On my site there’s a java apllet visible whichs shows my webcam. When clicking on an image, the lightbox shows with the image partly behind my java-applet. I know, this is common behaviour…
BUT…
The last part of the lightbox (the footer with the close button) shows OVER the java-applet. Will it be possible to make a next version that does that for the whole image?
Check for an example: http://www.devogelman.com/2010/02/walnoten-voor-de-winter/
Kind regards!
Ed
that was fantastically easy. i’ve only tested it a few times, but I just installed your plugin and it looks great. thanks.
Hi there,
I became a fan of your plugin when I tried a picasa gallery with lightbox 2 integrated. Now I’d like to use it on my whole website, but it interferes with my theme. The pics are ‘beneath’ the banner header. Can you tell me what to do to solve this? Thanks!
Hi!
The plugin works great for Firefox, but for IE8 it doesn’t. Any tips or tricks?
See the site in the link on my name…
Already fixed it with z-index!
Hi Rupert,
I love this plugin! It’s great and it makes your website more professional =). I was testing it on several browsers (IE8, Firefox 3.5 and Google Chrome). It worked all fine except Google Chrome. The Close X button doesn’t seem to work. Or am I the only one having this issue?
Keep up the good work!
In addition on my post above: Close X button doesn’t seem to work for larger size images (in my case: 1029×684). Smaller sizes works fine.
Why have you deleted the option to adjust the transparency and lightbox resize speed?
I really need these features.
This plugin is not working when you have Jquery Lazyload plugin activated, any suggestion?
http://wordpress.org/extend/plugins/jquery-image-lazy-loading/
I’ve got the IE8 problem too. The screen turns pitch black instead of dimming. FF works sweet.
Since upgrading to the latest version of Lightbox it no longer works consistently on Firefox on both Mac and PC. At http://daveingram.ca – images no longer clickable, Lightbox doesn’t seem to work (Pyrmont theme). On http://IslandNature.ca it doesn’t work on the main page (home.php) but for some reason seems to work on the single post pages (Gridline Magazine theme). Any ideas of where the conflict could be? Seems weird that it would work on one page in a blog but not another…
Thanks – love the plugin when it works!
My apologies – it seems to be the latest posts that don’t work i.e. the ones added after the last update. Older posts seem to be OK, just my latest two posts added yesterday.
Maurice: well done.
Khai: I can’t reproduce the bug on Chrome 5 Mac. Link?
TW: google ‘jQurey prototype conflict’
deVogelman: I will investigate.
Dave: Link?
How can i solve this conflict, can you tell me if possible?
The new version broke my site. It created a dropdown lightbox with menu that showed on every page of my site. Very odd. Worked great before the update. Now I have to keep it deactivated. You can check my site to see.. I’ll keep it “broken” for a couple days in case you want to take a look.
*plugin conflict*
read the FAQ
fair nuff.. i noticed i didn’t need the plugin too. strangely though, i couldn’t make the other plugin work w/out yours when i first tried.. which was why i added yours. now it seems the one plugin will suffice.
thanks for taking a look.
Hi! First of all, great plug in!
But I’m experiencing some problems because once in a while it doesn’t work (and the picture gets bigger as there would be no plug in). In order to make it work again I have to delete the cache. Do you have any idea how to fix it? I’m working on Wordpress 2.9.1, with a slightly modified defaul theme. I tested it with Firefox 3.5.8, Chrome 4 and IE 7. I had the same problem with alll of them.
Thanks a lot!
The lightbox is working fine on my website, but today suddenly lightbox won’t load for this image i uploaded.
All the other images are working and the settings are exactly the same.
Could this be a filesize problem or something?
Hey Rupert…thanks for all your hard work on this…simple Q:
any way to change the text @ the bottom of lightbox to the image filename instead of ‘Image __ of ___’
thx!
Hi Rupert,
I love your plugin and it worked great until the latest update (or at least somewhere around that time). Since 02/16/10 the images are being linked to a separate page, showing only the image (like so: http://don-f.com/blog/?attachment_id=71) Older posts are properly showing lightbox-behaviour (e.g. here: http://don-f.com/blog/?p=50) I’ve already tried deactivating all other plugins, but to no avail.
Is it possible the latest WP update (2.9.2) messed something up? My theme is in its original state.
Thanks a lot for any hints!
br, D.
The lightbox-2 plugin only works for White for me. The other colors do not work. Any ideas?
Maria: All the contents of your blog have to *finish loading* before lightbox activates. If one tiny thumbnail image is straggling, lightbox is not activated until it is done.
Steven: link?
Nathan: dig around in the lightbox.js and lightbox-resize.js
Don: It must have something to do with how you are adding images to posts. Make sure the link for the image is the *image URL*, ie: ends in .jpg. Be careful when posting not to select another option in the WP embed image thingie.
Robert: delete your chache, both for WP and your browser.
Brilliant, that did the trick! Thank you for your help. :)
br, D.
@Rupert: Thank you, that seems to work.
Thank you. that was exactly what I was looking for. Made my life much easier. Thanks.
How do I disable Lightbox 2.9 on a per page basis.
I have lightbox2 installed on my wp blog. I love it! Only problem is that the images in my last post which was created last night do not load with in lightbox. All settings are correct and equal to other posts on my site. Other post images seem to load in lightbox fine? I have checked plugins so that’s not the issue. Not sure what’s going on here? When clicked, the screen starts to darken like it usually does, but then it just opens to the actual image. The image doesn’t pop up in lightbox at all.
Please help me figure out why this is happening! ;)
Thanks,
Ry
Found it! Can you suggest a change? (instead of image 1 of 12…just display filename)
Element.setInnerHTML( ’stimuli_numberDisplay’, “Image ” eval(activeImage 1) ” of ” imageArray.length);
Hi: If I call jquey separately on a site, the Lightbox plugin trashes it (or vice versa depending on my call order. Anyone else have this issue?
Hi, i´d love to use this plugin.
I installed it like in the faq. I also activated it.
But now when i write the code for linking an image nothing happens. The picture shows up normally. What do i do wrong?
Fixed it. I deleted all of the uploaded images from my media library and re-up’ed them. After re-upping and inserting them back into the post it now works fine. Not sure what the problem was? I’d still be curious to find out…
Thanks for a great WP plugin.
Ry
Hi,
I have a question with Lightbox 2
Could it be that it has problems with some WordPress themes? I have one designed by mono-lab and installed Lightbox 2. Everything looks ok but it doesn’t work.
Perhaps you can help me :)
Kind regards
Libertas
Version 2.9.2… Going hand in hand with WordPress.. :)
Great plugin! I specially like that it does not add much to the page load time. Will give it a try.
great, it works again!:)
BUT …wher is the background color adjustment option???
ok, i found out how to change in the lb theme css. sorry for bothering. thanks for the plug!
Is there any chance you will include a slide show feature in the future??
Hello, thanks for your plugin! Is there a way I can resize the images like little squares like yours? For example, the image is shown as a little square thumbnail (like yours) and when clicked, it expands with lightbox 2?
Thanks a lot!
i don’t know why, but sometimes it works and somethimes not.
i dont know what to do.
please can you answer me to the mail?
i don’t know what happens what it works only it wants, the same image somtimes works, and sometimes not, what could i do?
Hi there,
I have had Lightbox 2 installed on my Wordpress blog for about a year and it has always worked like a dream.
However, the other day when I was checking a post – I noticed that images were no longer opening through Lightbox.
I have made no changes to the theme I have been using and have looked at all the possible causes I can think of – but can’t seem to get to the bottom of the problem.
Any ideas why it might have just suddenly stopped working?
Any suggestions would be most welcome!
Thanks
John
Hello!
I really love your plugin and find usefull the auto lightbox option but I need to avoid the light boox in 4 images I used on the homepage of my wp blog.
Can you tell me what I need to add to do this? You’d be very very kind!
Thanks!
Hello I would like to know why when I link an image I do not get a thumbnail, instead I just get a normal link. Though when I click on the normal link instead of opening a new page with the link on it, it opens the light box. How do I get the thumbnails to work?
The link to my post is as follows:
http://www.talksontech.com/smartqv7-review/2/
After the “Design” section I have links to various pictures that simply won’t display thumbnails.
Any help would be appreciated! Thankyou!
PeterV
I was having problems getting this (or any!) lightbox style to work, eventually worked out it was because I had “featured_gallery” plugin activated which came with the theme I was working with. Not sure if anything can be done to fix this, I’ll work around it but it might help someone else get it working!
Great plugin, but will not run on the same page as “YouTube with fancy zoom” which also utilizes some sort of lightbox. I don’t want to give up on either, so hopefully the incompatability will be fixable?
Hy can you help me with something I tried for a few days and just couldn’t do it?
When I click on the image and it opens I want in stead of Image % of % to show the category from which the picture takes part?
Like in a post when you can click the category link and it takes you to http://domain.com/category.
If my explanation is to weird:
How can I add links next or under the title of the picture in the plugin when you click a image like here, in stead of the Boy and his Turtle to show a link.
Again ;)
I have done all the things in the FAQ.
I installed it like in the faq. I also activated it.
But now when i write the code for linking an image nothing happens. The picture shows up normally.
Did i forgot to add something in any .php?
What do i do wrong?
My Page is here http://fraubeutel.de/
I would be so happy if you could help me, i´m pretty new in Wordpress but try the best. ;)
Cheers for the plug-in, although im pretty sure this is theme related but over at statusevents.co.uk the images are not positioning properly in the bounding box. I was wondering if anyone has any thoughts/tip/tricks to fix this,
Thanks
Dom
Did anyone figure out how to remove the line beneath the images? Or how to remove the lightbox on a per page basis?