I have a template file in my Zen5 sub theme to style the user profile page. The file is called user-profile.tpl.php.
I use the Profile2 module to give users of certain roles extra information. That info needs to be presented on that template.
One of the fields is an image field containing 5 images. I'd like to display those using Lightbox2 7.x-1.0-beta1+9-dev.
I'm using this code in my template:

foreach ($images as $image) {
print '<div class="image">';
print theme_lightbox2_image(array(
'item' => $image,
'image_style' => 'medium', //The size of the image you show on the page
'lightbox_type' => 'lightshow', //lightbox
'field_name' => 'field_images',
));

This works fine on my development system. BUT, if I switch the "Rebuild theme registry on every page" OFF, the page doesn't work and I get an error in my Apache log saying
Call to undefined function theme_lightbox2_image()

Adding module_load_include('inc', 'lightbox2', 'lightbox2.formatter'); to my template fixes the issue for now.