Scott Bradford: Off on a Tangent

Gallery Shortcode Style to Head

Last Updated January 15, 2011 4:46pm ET

Plugin Settings Screen

This WordPress plugin moves the gallery shortcode styles to the head so it doesn’t break XHTML validation; also allows disabling or modifying the default gallery styles.

By default when using the WordPress gallery, the styles are placed into the post content which breaks XHTML validation. This plugin moves the style into the head of the page using a look-ahead to determine if the  shortcode is used in any posts.

This plugin also gives you the option to modify the default gallery style CSS or disable the gallery styles entirely (so you can control it from your template CSS files).

This plugin uses ideas recommended in a patch located at:
http://trac.wordpress.org/attachment/ticket/6380/6380-style.diff

Special thanks to the original author of this plugin, Matt Martz, http://sivel.net.

Version Information

Version: 2.1
Requires WordPress Version: 2.9
Compatible up to: 3.1
Last updated: January 15, 2011
License: GNU General Public License (GPL)

Installation

Installation is just like any other WordPress plugin:

  1. Upload the ‘gallery-shortcode-style-to-head’ folder to the ‘/wp-content/plugins/’ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

Immediately after installation, your galleries should pass W3C XHTML validation. You can make further adjustments under Admin > Settings > Media.

Frequently Asked Questions

How do I make the WP galleries XHTML compliant?

  1. Just activate the plugin. Nothing else is required.

How do I adjust the default gallery CSS styles?

  1. In WP admin, go to Settings > Media.
  2. Scroll down to “Modify gallery CSS style.’”
  3. Adjust to your liking!
  4. Click “Save Changes.”

How do I disable the CSS styles (so I can control the CSS in my template)?

  1. In WP admin, go to Settings > Media.
  2. Scroll down to “Disable gallery CSS in ‘head.’”
  3. Check the box.
  4. Click “Save Changes.”

How do I reset the gallery CSS styles to default?

  1. In WP admin, go to Settings > Media.
  2. Un-check the setting for “Disable gallery CSS in ‘head’.”
  3. Clear everything in the “Modify gallery CSS style” text field (so it’s totally empty).
  4. Click “Save Changes.” The styles will be reset to default.

Download

Support

Please contact me with any support requests or bug reports. Thank you!

Archives

Random Links

For the whole list of links, go to the links page! (Note: A link is not necessarily an endorsement.)

Have a Quote

Loading...

Scott Bradford has been building web sites and using them to say what he thinks since 1995, which tended to get him in trouble with power-tripping assistant principals at the time. He holds a bachelor’s degree in Public Administration from George Mason University, but has spent most of his career (so far) working on public- and private-sector web sites. He is not a member of any political party, and brands himself an ‘independent constitutional conservative.’ In addition to holding down a day job and blogging about challenging subjects like politics, religion, and technology, Scott is also a devout Catholic, gun-owner, bike rider, and music lover with a wife and two cats.

Like what you're reading?

Please consider making a small donation to support Off on a Tangent.
Also please be sure to 'like' us on Facebook!