How To Add A Title To Images In The NextGEN Gallery Plugin

So as I’m modding Gwen’s site, I had a problem: In the lightbox for each page, the art was displayed when you clicked on it, but with only a description, not a title.

A few years back, I had made a mod to the NextGEN gallery plugin to manage it, but with WordPress plugin updates, it had been wiped out; as well, the plugin seems to have been rewritten, making the issue moot.

The key to fix it is to make sure the tag in the galleries includes a title along with the description – the file I modded was found in


And the actual change I did was found in here:

<div class="ngg-gallery-thumbnail">
  <a href="<?php echo esc_attr($storage->get_image_url($image, 'full', TRUE))?>"
    title="<?php echo esc_attr($image->description)?>"
    data-src="<?php echo esc_attr($storage->get_image_url($image)); ?>"
    data-thumbnail="<?php echo esc_attr($storage->get_image_url($image, 'thumb')); ?>"
    data-image-id="<?php echo esc_attr($image->{$image->id_field}); ?>"
    data-title="<?php echo esc_attr($image->alttext); ?>"
    data-description="<?php echo esc_attr(stripslashes($image->description)); ?>"
    data-image-slug="<?php echo esc_attr($image->image_slug); ?>"
    <?php echo $effect_code ?>>
        title="<?php echo esc_attr($image->alttext)?>"
        alt="<?php echo esc_attr($image->alttext)?>"
        src="<?php echo esc_attr($storage->get_image_url($image, $thumbnail_size_name, TRUE))?>"
        width="<?php echo esc_attr($thumb_size['width'])?>"
        height="<?php echo esc_attr($thumb_size['height'])?>"

I changed line #03 to add the title:

title="<?php echo esc_attr($image->alttext),": ",esc_attr($image->description)?>"

Voila – a title below each lightbox image – as the screen shot below shows.

I even tried with with <strong> (or <b> if your theme handles it properly) to bold the title:

title="<?php echo "<strong>",esc_attr($image->alttext),":</strong> ",esc_attr($image->description)?>"

But in the end, adding html within a <img> tag parameter didn’t feel right, so I went back.

Some caveats with this method:

  • It works because the title= parameter in the <img> tag is used by the FancyBox lightbox code to caption the images. If you use one of the other lightboxes in NextGEN, this may not work.
  • Likewise, it’s for the Basic Gallery display – if you want it to work for another type of gallery and this doesn’t work, then plan to spelunk your way through the code looking for the appropriate place to patch.
  • And of course, patches will disappear with the new update. So make the change, check it out, and then backup the file (maybe even the whole plugin.) And plan to fix it every update.


Arcade Wordpress Online Games Affiliate Website For Sale 3 Months Hosting FREE
End Date: Monday Feb-26-2018 6:42:29 PST
Buy It Now for only: $8.99
Buy It Now | Add to watch list
44 Professional Wordpress Videos With Resell Rights + Bonus FB Games w/ Resell
End Date: Sunday Mar-25-2018 1:41:50 PDT
Buy It Now for only: $5.99
Buy It Now | Add to watch list
400 Wordpress Themes With Resell Rights / Mega Package / Email Delivery /
End Date: Sunday Mar-25-2018 1:37:03 PDT
Buy It Now for only: $12.90
Buy It Now | Add to watch list

One thought on “How To Add A Title To Images In The NextGEN Gallery Plugin

  1. Hi, would this work to display a caption under the thumbnail image in the basic gallery, not only when in lightbox effect view?

Leave a Reply to Lina Cancel reply

Your email address will not be published. Required fields are marked *