A cleaner WordPress [gallery] that integrates with multiple Lightbox-type scripts.
This plugin was written to take care of the invalid HTML 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.
<fig>
and <figcaption>
elements.aria-describedby
attribute to make images + captions more accessible to users with disabilities.If you need professional plugin support from me, the plugin author, you can access the support forums at Theme Hybrid, which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 40,000+ users (and growing).
If you’re a theme author, plugin author, or just a code hobbyist, you can follow the development of this plugin on it’s GitHub repository.
Yes, I do accept donations. If you want to buy me a beer or whatever, you can do so from my donations page. I appreciate all donations, no matter the size. Further development of this plugin is not contingent on donations, but they are always a nice incentive.
cleaner-gallery.zip
folder.cleaner-gallery
folder to your /wp-content/plugins
directory.Gallery from the Socially Awkward theme.
Gallery from the Chun theme.
Gallery from the Picturesque theme.
Cleaner Gallery settings page.
cleaner-gallery.zip
folder.cleaner-gallery
folder to your /wp-content/plugins
directory.The purpose of the Cleaner Gallery plugin is to get rid of the invalid HTML output by the default WordPress [gallery]
shortcode. Since I was having so much fun with it, I decided to make it compatible with several Lightbox-type image scripts.
It has eventually grown into an extremely robust and flexible image script.
If you expect multiple columns of images but only have one column, it’s most likely that your theme is doing something incorrectly.
Also, the Cleaner Gallery plugin stylesheet doesn’t load if your theme supports cleaner-gallery
. If that’s the case, it’s your theme’s responsibility to style the gallery output.
It’s impossible for me to say for sure without looking at your site. More than likely, your theme is overwriting the gallery styles. You’d need to stop by my support forums for support for your specific case.
The plugin has been tested and works with many different Lightbox-type image scripts. They are all listed in the plugin description.
I don’t officially support any third-party code whatsoever. However, I’m more than willing to attempt helping you set up your preferred image script via my support forums.
There’s a good chance that I will. It really depends on how feasible it is. Some scripts would require re-coding how the plugin works, which is something I probably won’t do. However, most scripts don’t require this.
If you’d like for me to add a new image script, please provide me with as much information as you can. Particularly, a link to the page where I can download the script and view a demo of it. That will go a long way towards getting support for the script included in this plugin.
Technically, you don’t have to set up anything at all. It should work right out of the box.
However, you do have several configuration options that you can set from the “Appearance > Cleaner Gallery” screen in the admin.
If you’re building a WordPress theme, it’s extremely simple to add support for this plugin. Simply add the following line to your theme’s setup function:
add_theme_support( 'cleaner-gallery' );
Then, copy the plugins css/gallery.css
file into your theme’s stylesheet. You are free to make any customizations you wish. It’s much more flexible than the default WordPress gallery, so you have a lot of freedom with design choices.
Customizing your galleries can be very simple. Here’s some CSS you can add to your theme’s style.css
and modify.
/* Style rules for the entire gallery */ .gallery {} /* Style rules for each item (image and caption) in the gallery */ .gallery-item {} /* Style rules for images within the gallery */ .gallery-icon {} /* Style rules for captions within the gallery */ .gallery-caption {}
While the plugin has no way of paginating its own galleries, it’s very much possible to make this happen using the WordPress <!--nextpage-->
tag.
Let’s suppose we have 12 images we want to show. The first six will be on the first page while the following six will be on the second page. You’d use this code in the post editor:
[gallery numberposts="6"] <!--nextpage--> [gallery numberposts="6" offset="6"]
Cleaner_Gallery
class, which allows for better code reuse and consolidates all the gallery functionality..gallery-columns-x
class..gallery-size-x
class.aria-describedby
attribute for images with captions for better accessibility.<fig>
and <figcaption>
tags.add_theme_support( 'cleaner-gallery' )
method.cleaner_gallery_image_link_class
filter hook.cleaner_gallery_image_link_rel
filter hook.add_image_size()
WordPress function./languages
folder.offset
argument so that users could more easily make paginated galleries.cleaner_gallery_id()
function to make sure multiple galleries in a single post have different IDs but the same class.cleaner_gallery_defaults
filter hook.cleaner_gallery_default_settings()
function to better handle user settings.cleaner_gallery_link_attributes()
).wp_enqueue_style()
.’numberposts
parameter.exclude
parameter.include
parameter.[gallery columns="0"]
error.