I created a plugin for WordPress that helps you to embed ThickBox into your blog. Just install and activate the plugin, add ThickBox compliant markup wherever you want and you’re all set. Furthermore, you can use SmoothBox instead of ThickBox if you like.
You can download the plugin here.
How to
Once you activate the plugin it’ll include the CSS and JavaScript for ThickBox into each and every page on your blog. This way you can put ThickBox compliant markup wherever you want and everything should work as expected.
Have a look at these examples if you’d like to know how to insert the code into a post or page. For the gallery on this page I used the following markup:
<a href="[...]/images/flower.jpg" title="Flower" class="thickbox"> <img src="[...]/images/thumbs/flower.jpg" alt="Flower" /> </a>
All you have to do is to put an img tag inside an a tag where the former holds the smaller and the latter holds the larger image. This results in a nice image gallery.
Configuration
The plugin comes with a settings page that helps you to adapt the plugin’s behavior to suit your needs. Although most of the options are pretty self explanatory there’s a help link next to every option.
Help
If the cool effect doesn’t seem to appear, go check these things:
- Is your markup correct? Have a look at the examples and learn how to supply markup ThickBox understands.
- You had ThickBox on your site and switched to Smoothbox and now it isn’t working? Don’t forget to set the
classtosmoothboxinstead ofthickboxin the HTML markup. In this regard, the libraries aren’t compatible with each other. - Is the CSS and JavaScript included in your page? If you enabled the expert mode don’t forget to add the custom field
thickboxto your page. Finally, make sure your theme has calls towp_headandwp_footerinheader.phpandfooter.phprespectively.
Still need help? Write a comment.
Special use cases
Here I collect some special issues regarding ThickBox.
Changing ‘close or Esc key’
The plugin comes with the default (english) and a german translation of ThickBox and SmoothBox. Whether you just want to change the text saying close or Esc key or add more internationalization to ThickBox you can do it like so:
- download the uncompression version of ThickBox from here.
- do a search and replace, so everything fits your needs. For example, change close or Esc key on lines 128, 196 and 204.
- optional: compress the JavaScript with a tool.
- copy the new JavaScript file over the original one in the plugin located under
wp-content/plugins/thickbox/thickbox/thickbox.js.
Once you’ve done that the ThickBox is customized to suit your needs. But instead of replacing the original version of ThickBox you can read more about variants in the corresponding help box on the plugin’s settings page; indeed, you can manage more than one variant with the plugin.
Open ThickBox onload instead of onclick
In case you’d like to open a ThickBox onload instead of the usual onclick here you go:
- add the following JavaScript snippet to your HTML header, i.e. somewhere inside the
headelement:<script> function showThickbox() { $(document).ready(function() { tb_show("Page", "somepage.html?height=200&width=400", ""); }); } </script>Adapt
Pageandsomepage.htmland the following parameters to suit your needs. - Add this
onload="showThickbox()"to e.g. thebodyelement. This way the Thickbox loads every time the page loads.
That’s it. Now use PHP to to add some sophistication to this.
You can download a working example here; have a look at the file test.html first.
Examples
A simple gallery of images might look like this:
An iFrame is easy too.
170 comments ↓
Vielleicht wäre es eine einfache Lösung, eine Option im Plugin einzuführen, die es ermöglicht, die thickbox.js und jQuery.js Einbindung zu deaktivieren – für den Fall, dass man beide Bibliotheken schon selbst im Header eingebunden hat. So würden sich die in dem Fall unnötigen doppelten Einbindungen sparen.
Viele Grüße und danke für das coole Plugin!
Tom
have a look at this new feature.
Again thanks for this cool plugin and your work!
- Tom
I don’t really know why, but it does not work anymore.
I have WP 2.6.1 and Thickbox 1.2.1. I’ve added the ‘class=”thickbox”‘ to each a-tag, but it’s just not working.
What kind of CSS or Script must be in the head-part of the document, that thickbox is working?
Could you please take a look:
images: on the column “VER”
ajax content: column “+ info”
the web
http://tinyurl.com/6f2v7h
thanks a lot, have a nice day
hm, the markup looks valid but it doesn’t work for me either. Since the page has JavaScript errors, maybe you should debug those with FireBug first.
I came across this thread, and was hoping someone could help, im going crazy! I’ve been developing a site with jQuery tabs, innerfade, and swfObject, with much success. My plan was to integrate thickbox for the individual images, but for some reason, i can’t even get thickbox to kick in. The browser just goes right to the image in a new window. I know it’s something silly, could anyone help me out? I’ve worked with lightbox quite a bit, but even that wouldn’t work when i tried integrating it onto the page. Right now i’m just testing on one page, the first thumbnail (phoenix adult), that should definitely be doing some thickbox magic…have a look at the code…
http://dev.creativehinge.com/portfolio_temp.php
Do you know if is any way to use Thickbox with video tutorials like they do it in camtasia hompage?
Thanks.
I’ve added an iFrame example for you here. Read more about this over here.
I think there is a minor bug with the loading gif and using pretty permalinks. With pretty permalinks the relative path to the loading gif changes. I am using smoothbox and updated smoothbox.js on line 53 to read:
$(’TB_load’).innerHTML = “”;
instead of:
$(’TB_load’).innerHTML = “”;
My problem was a box that contained Inline Content and I wanted Next and Previous links for it. The thickbox removes the “original content” and puts it into TB_ajaxContent. So I had to make some changes into thickbox.
First: I have divs id=”x1″, id=”x2″, and so on. The link in the original thickbox link is &inlineId=x1, and so on. In the divs, I have next and previous links onclick=”changeContent(’x3′);” and onclick=”changeContent(’x1′);” (this is div id=”x2″). The function
After this I found out that thickbox empties the “original div” – SO in thickbox.js (not compressed) I changed:
to:
Hope this helps someone.
I’ve got nextGEN Gallery installed in plugins and it’s working fine, except for the multitude of validation errors. I’ve downloaded smoothbox.css, smoothbox.js and loading.gif
I have no clue where to place these files so that nextGEN can use them instead of Thickbox. I tried just placing them in the nextgen-gallery -> thickbox directory and then seeing if I could select smoothbox in the nextGEN wordpress preferences Gallery -> Effects -> Custom but didn’t have any luck with that. I’m lost, dazed and confused.
this isn’t an extension to NextGen Gallery and I can’t help you with that plugin. Go to this website and ask your question there.
If i install this plugin, all my imagens don’t have class=”thickbox”
How to add this for all images ??
there’re various plugins that do a search and replace in your content. Use one of these and try replacing
imgwithimg class="thickbox". That will enable the ThickBox effect on all your images.Please make a backup of your WordPress database before doing this.
At the same page, you can download a .zip file with an alternative CSS file and a Javascript that you can use to fix the problem if you don’t use WordPress.
cheers
instead of fixing Thickbox you can use Smoothbox instead.
Thanx for your attention
B.
please send me a link to the page with the ThickBox and I’ll have a look…
Here it is the URL http://www.hiphopconnection.it/v3/category/info
Click on the last image with the black cat “Bronx”.
You can see the “thickbox” class from the browser’s source code.
Many thanx
B.
although the CSS in the HTML head is present the JavaScript in the footer is missing. Check whether there’s a call to
wp_footer()in thefooter.phpof your theme – if that’s not the case, you’ll have to add it.BTW: the markup of your site is totally broken; validate with validator.w3.org. Have a look at line 54: seems like another call to
wp_head()in your theme. Try fixing this too.Many thanx again.
B.
I have a new Wordpress site I’m working on — version 2.7 — and I’m wondering if this still works in this version? I did exactly as instructed — activated it and tried to implement a simple image thickbox example. However, nothing happens. I’ve tried hardcoding the css and js references in the header myself but agai, nothing. Am I missing something obvious?
Wait, I got it. The js had to be in the footer — and wasn’t be included in mine for one reason or another.
My next question then is — can Quicktime movies be used here? So far it doesn’t seem to work, but I thought I’d check.
Thanks, C
Sure: use an iFrame for this. Have a look at my example on this page.
Leave a Comment