• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

nSiteful Web Builders

Building a Better Web - One Site at a Time.

  • Home
  • About
    • Testimonials
    • Resources
    • Partner With Me
    • Frequently Asked Questions
  • Web Sites
  • Online Marketing
  • WordPress Support
    • Customized WordPress Training
    • 60-for-60 Sessions
  • Web Applications
  • Blog
    • At-A-Glance
    • Blog Articles Grouped by Category
    • Case Studies
    • General
    • Portfolio
    • Reviews
    • Snippets
    • Techniques
    • Projects
  • Contact
    • Purchase Retainer Consulting Hours
    • About Retainer Consulting Hours
    • Book a Meeting with Jeff
    • Tell Me About Your Web Project
    • nSiteful Newsletter Archives
    • nSiteful Rewards

By Jeff - 2/9/2012
Cats: Snippets · Tags: NextGen Gallery, Photo Gallery, Plugins, WordPress

snippets

NextGen Gallery Compact Album Mods

Last updated May 7th, 2024 at 03:06 pm

This article describes how to customize aspects of the NextGen Gallery plugin by modifying an NGG template and making corresponding CSS modifications.

You gotta love the NextGen Gallery plugin for WordPress. It is to image galleries in WordPress what Irfanview is to desktop image management.

But not everything about NGG is wonderful.

Take the compact album template, for example.

Today I ran into problems with the rendering of the the thumbnail images which correspond to the galleries within an album. Namely, these thumbnail images were distorted, being resized oddly by the CSS in the plugin’s stylesheet. In addition, the gallery names and image counts for each gallery — essentially the captions for each thumbnail — weren’t lining up quite right.

Before:

Before

After:

After

Initially, I attempted to fix things simply by adding overriding CSS rules in my child theme style sheet. But after (a) going through hoops to write CSS declarations that defeated the bad stuff in the NGG style sheet and (b) seeing that the template itself could be improved, I revised my approach.

Sometimes it’s just easier to start from a nearly blank slate.

In a nutshell, I cloned and modified the NGG template file and then created new CSS declarations to target the new CSS classes.

Key Principle #1:

If your active theme includes a folder called nggallery and that folder includes a file whose filename is identical to the NGG template file that NGG is looking for, your theme’s template file will supersede the native NGG template file.

I’m using the “compact” album theme, whose filename is “album-compact.php”. So I located that theme in the “/view/” folder of the NGG plugin…

/wp-content/plugins/nextgen-gallery/view/

…and copied it into the new /nggallery/ folder of my (child) theme.

Rearrange Template Components

I prefer to wrap images and their caption information in a targetable container. I think that makes it much easier to position all the pieces properly.

The native NGG template didn’t do this. Note below that the native container — “ngg-album-compactbox” lines 2-8 — does not contain the album description, gallery title, or count of images:

Native NGG Template:

<div class="ngg-album-compact">
	<div class="ngg-album-compactbox">
		<div class="ngg-album-link">
			<a class="Link" href="<?php echo $gallery->pagelink ?>">
				<img class="Thumb" alt="<?php echo $gallery->title ?>" src="<?php echo $gallery->previewurl ?>"/>
			</a>
		</div>
	</div>
	<h4><a class="ngg-album-desc" title="<?php echo $gallery->title ?>" href="<?php echo $gallery->pagelink ?>" ><?php echo $gallery->title ?></a></h4>
	<?php if ($gallery->counter > 0) : ?>
	<p><strong><?php echo $gallery->counter ?></strong> <?php _e('Photos', 'nggallery') ?></p>
	<?php endif; ?>
</div>

So I made mods to my cloned template. They were few and simple:

  1. I renamed the container div class (adding the numeral “2” in line 1) to avoid competing with style rules in the NGG style sheet.
  2. I then created a new container div (class of “item-container”, line 2) to contain the thumbnail image and all the “meta” stuff.
  3. I wrapped the “meta” stuff in a div with a class name of “meta” (line 8).
  4. Then I created new CSS declarations in my child theme style sheet, targeting the new class names.

Here’s the template…

Customized Template:

<div class="ngg2-album-compact">
	<div class="item-container">
		<div class="ngg-album-link">
			<a class="Link" href="<?php echo $gallery->pagelink ?>">
				<img class="Thumb" alt="<?php echo $gallery->title ?>" src="<?php echo $gallery->previewurl ?>"/>
			</a>
		</div>
		<div class="meta">
			<h4><a class="ngg-album-desc" title="<?php echo $gallery->title ?>" href="<?php echo $gallery->pagelink ?>" ><?php echo $gallery->title ?></a></h4>
			<?php if ($gallery->counter > 0) : ?>
				<p><strong><?php echo $gallery->counter ?></strong> <?php _e('Photos', 'nggallery') ?></p>
			<?php endif; ?>
		</div><!-- .meta -->
	</div><!-- .item-container -->
</div><!-- .ngg2-album-compact -->

And here are the three new lines of CSS:

New CSS


.ngg2-album-compact .item-container {
	width: 140px;
	display: block;
	float: left;
}

.ngg2-album-compact .item-container img.Thumb {
	border: 4px solid #ccc;
}

.ngg2-album-compact .item-container .meta {
	font-size: .8em;
}

HTH. Comments and questions are welcome.

Like what you see? Share with others and join my mailing list. No long-term commitment, unsubscribe any time.

Related Posts

  1. Give Gutenberg a Chance
  2. iPhone Video: Land, Front Up, Back Down.
  3. Dive Into WordPress Custom Post Types – Part 3
  4. Tent Birth and Breastfeeding Services
  5. CSS Descendant Selectors

Reader Interactions

Comments

  1. ganhar dinheiro says

    June 5, 2012 at 12:30 pm

    I was searching for NextGen Gallery Compact Album Mods | nSiteful Tech Blog on google and i found your blog! Thanks

    Reply
  2. Mark says

    March 12, 2014 at 9:42 am

    Thank you for this mod!!! That is exactly what I need.

    Can you just tell me how can I change distance between lower and upper album thumbs?
    And how to make the preview is below the text?

    Thank you.

    Reply
    • Jeff Cohan says

      March 12, 2014 at 5:34 pm

      Mark – Can you provide the URL?

      Reply
      • Mark says

        March 13, 2014 at 5:41 am

        Yes, of course. Example page with album – http://ma-lkmodels.ru/boys/

        Reply
        • Jeff Cohan says

          March 13, 2014 at 8:43 am

          If you’re asking how to increase the spacing between each row of thumbs, I’d do that by adding a ‘margin-bottom’ declaration to the stylesheet. Here is your CSS rule to which I’ve added a new line:
          .ngg2-album-compact .item-container {
          display: block;
          float: left;
          padding-right: 26px !important;
          width: 140px;
          margin-bottom: 48px;
          }

          Here’s the before: Before
          Here’s the after, with that margin: After

          To swap the positions of the preview image and text, you’d have to move those sections in the template file. But again, I recommend you do this in a cloned version of the template file which you store as described in my article. Hope this helps.

          Reply
  3. Mark says

    March 17, 2014 at 8:42 am

    Hi Jeff!

    Can help with one more thing? I noticed that in the album galleries preview with big names violate the order of other previews. Do you think it can be corrected? Look at the end of this page for example – http://ma-lkmodels.ru/girls/

    Reply
    • Jeff Cohan says

      March 17, 2014 at 9:17 am

      If I understand, your problem here is that a NextGen Gallery thumb container will push downward the thumb(s) below if the caption wraps to 2 lines or more.

      Probably the easiest solution is to alter your CSS for this…
      .ngg2-album-compact .item-container .meta
      …and give it an explicit height that large enough for the multi-line names to fit.

      HTH

      Reply

Leave a Reply Cancel reply

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

Primary Sidebar

mailchimp signup

Subscribe to get notified when new articles are published. Unsubscribe any time. No spam. I promise. Check out my newsletter archives.

social

Twitter Facebook LinkedIn

Recent Articles

  • Post-Specific CSS for WordPress October 5, 2026
  • You built an online course, but they haven’t come. September 16, 2026
  • Custom MemberPress Pricing Pages December 19, 2025
  • CSS Data Attribute Override December 11, 2025
  • MemberPress Rules Using Custom Taxonomies and Custom Roles December 10, 2025

Filter By Category/Tag

Categories

  • Case Studies (8)
  • For Staff (1)
  • General (73)
  • Portfolio (7)
  • Reviews (14)
  • Snippets (24)
  • Techniques (52)

Popular Tags

Advanced Custom Fields Blogging Child Themes Content Marketing CSS Customer Service Custom Fields Custom Post Types Diagnostics Domain Names Facebook FooGallery Genesis Hosting HTML Images iPhone Libra Live Chat Marketing Media MemberPress MemberPress Courses Membership Sites Mobile-Friendly MySQL Photo Gallery php Pinterest Plugins Post Formats Pricing Project Management SEBA SEO Seth Godin Shortcodes Social Networking Surveys Taxonomies Twitter Video Web design Web forms WordPress

Footer

Background

Web Sites | WordPress Support | Web Applications.

Formally trained in liberal arts and education (I have a B.A. in Government from Harvard and studied Secondary Education at Rutgers Graduate School), I have honed my skills in the communication arts and sciences as a teacher, trainer, instructional designer, writer, photographer, calligrapher, helpdesk manager, database programmer, and multimedia developer.

(I've also been a group counselor, waiter, bartender, bicycle messenger boy, computer salesman, carpenter's helper, financial analyst, and school board president.)

Tech

Systems since 1983.
Web sites since 1994.
PHP since 2001.
WordPress since 2007.

Contact

Book Meeting
770-772-5134
Email Jeff
Send Money
All Ways

Copyright 2026, nSiteful Web Builders, Inc.

Cookies Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}
https://iframe.mediadelivery.net/embed/392008/42d18bc1-2adc-4741-b733-053d08d09c32
https://vz-000c5976-3ab.b-cdn.net/42d18bc1-2adc-4741-b733-053d08d09c32/play_720p.mp4

Receive occasional emails from Jeff