I used to have a separate JQuery plugin for lightbox, until I found this one – Using WordPress native thickbox.

Most of the time, I use the lightbox for gallery purpose. However, that has helped me cut down another JQuery plugins!
After following the tutorial at http://blog.manchumahara.com, that remind me of how I apply the gallery lightbox.
Open functions.php,
Add in gallery file type, the normal extension:
define("IMAGE_FILETYPE", "(bmp|gif|jpeg|jpg|png)", true);
Add a function for it, so it will automatically add a class to any image that has a link attached with it.
function wp_thickbox($string) {
$pattern = '/(<a(.*?)href="([^"]*.)'.IMAGE_FILETYPE.'"(.*?)><img)/ie';
$replacement = 'stripslashes(strstr("\2\5","rel=") ? "\1" : "<a\2href=\"\3\4\"\5 class=\"thickbox\"><img")';
return preg_replace($pattern, $replacement, $string);
}
Then add in another function that will automatically add a rel to bulk images. Works for gallery.
function wp_thickbox_rel( $attachment_link ) {
$attachment_link = str_replace( 'a href' , 'a rel="thickbox-gallery" class="thickbox" href' , $attachment_link );
return $attachment_link;
}
Use add_filter to force the usage:
add_filter('the_content', 'wp_thickbox');
add_filter('wp_get_attachment_link' , 'wp_thickbox_rel');
Full code:
define("IMAGE_FILETYPE", "(bmp|gif|jpeg|jpg|png)", true);
function wp_thickbox($string) {
$pattern = '/(<a(.*?)href="([^"]*.)'.IMAGE_FILETYPE.'"(.*?)><img)/ie';
$replacement = 'stripslashes(strstr("\2\5","rel=") ? "\1" : "<a\2href=\"\3\4\"\5 class=\"thickbox\"><img")';
return preg_replace($pattern, $replacement, $string);
}
function wp_thickbox_rel( $attachment_link ) {
$attachment_link = str_replace( 'a href' , 'a rel="thickbox-gallery" class="thickbox" href' , $attachment_link );
return $attachment_link;
}
add_filter('the_content', 'wp_thickbox');
add_filter('wp_get_attachment_link' , 'wp_thickbox_rel');
Done! It works with pages (internal or external), iframe content and even AJAX content. For more information about how to use this plugin, go to: http://jquery.com/demo/thickbox




