Cleaner Gallery was written to take care of the invalid XHTML that WordPress produces when using the [gallery]
shortcode.
It does a bit more than that though. It will integrate with many Lightbox-type scripts and allow you to do much cooler things with your galleries. Plus, it has a couple of extra options that you can play around with.
cleaner-gallery.zip
folder.cleaner-gallery
folder to your /wp-content/plugins
directory.Once you've activated the plugin, you don't have to do anything else for clean, valid XHTML galleries.
However, there are a few options you can set. Go to Cleaner Gallery, which is located under your Appearance menu in your WordPress dashboard. From there, you'll see several settings to choose from.
Oh yeah, you might want to know how to actually use the gallery shortcode as well. I would say that's fairly important.
In addition to the the normal gallery shortcode attributes, Cleaner Gallery gives you three extra attributes you can enter. These additional settings allow for cool things like showing multiple galleries in a single post.
The Image Link setting will override the WordPress gallery link and allow you to link your images how you want.
link
argument.The Captions settings are pretty self-explanatory. You can choose to remove all captions, use the image title when no caption is present, and/or link the captions to the image attachment page.
The Default Image Size, Default Order, and Default Orderby allow you to select site-wide settings. These can be overwritten on a post-by-post basis.
I imagine this is the reason many of you downloaded the plugin. It will integrate nicely with many different Lightbox-type scripts. Here is the officially supported list. This plugin has been tested and works with any of these.
To use one of these, you only need to load the appropriate JavaScript and/or CSS and select one from the Image Script drop-down box (see below if your script is not listed here).
Thickbox is a script that is included with WordPress, so you have the option of doing nothing other than selecting a couple of checkboxes.
That's it! Choose Thickbox from the Image Script drop-down and check the Thickbox JavaScript and CSS boxes and look at your new galleries.
If you're using a Lightbox-type script that this plugin doesn't support yet, you should let me know. I'll be happy to add the appropriate code. Since it's usually a while between updates, I've added two input boxes for adding custom class
and rel
attributes to each gallery item. Most Lightbox-type scripts require one or both.
You might input something like justinbox
in the class
input box and justinbox[gallery-id]
in the rel
input box.
Take note that by inputting id
in either box, the gallery will automatically exchange that with a unique ID so that you can have more than one gallery on a page (i.e. your blog's home page).
Customizing your galleries can be very simple. Here's some CSS you can apply to your theme's style.css
file.
.gallery {
/* Style rules for the entire gallery */
}
.gallery-item {
/* Style rules for each item (image and caption) in the gallery */
}
.gallery-icon {
/* Style rules for images within the gallery */
}
.gallery-caption {
/* Style rules for captions within the gallery */
}
You can also style individual galleries. All you need to do is figure out the ID of the particular post the gallery is for. So, you could style the gallery for post 95
like so:
#gallery-95 {
/* Style rules specifically for the gallery associated with post ID of 95 */
}
If you want even more control over your gallery style, you could get rid of the default stylesheet and load your own. So, what you'd do first is add this to your theme's functions.php
file:
<?php remove_action( 'wp_head', 'cleaner_gallery_css' ); ?>
This will disable the default gallery styling. You could then create completely custom style rules. A good place to start would be copying the contents of cleaner-gallery.css
into your theme's style.css
and altering bits and pieces at a time.
I run a WordPress community called Theme Hybrid, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 USD at the time of writing).
I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.
Cleaner Gallery is licensed under the GNU General Public License, version 2 (GPL).
This plugin is copyrighted to Justin Tadlock.
2008 – 2009 © Justin Tadlock. All rights reserved.