Wordpress Logo

When I was building the property gallery for greekislandpropertyfinders I wanted to use a fancy javascript image gallery like Galleria, however I came across a problem with Galleria in that it couldn’t display more than one gallery on any page. It’s open-source so I used the source code to help write my own version and turned it into a WordPress plugin with the features I needed.

The plugin isn’t all that generalised, so I’m not sure it’ll be useful to many people but I think it’s a tool worth sharing.

Plugin features:

  • This plugin doesn’t change the WordPress media gallery admin interface – galleries are created and inserted into pages/posts as normal (i.e. using the media upload GUI + the
    [gallery]
    shortcode). WordPress authors won’t need to change or learn anything new.
  • The plugin makes efficient use of WordPress media (no front-end image resizing via CSS!) which means it doesn’t matter if one of your authors uploads a load of 3MB images to a gallery – it’ll still run fast.
  • The plugin doesn’t pre-download images that aren’t needed – it displays a loading spinner image when the user is waiting for a image on load.
  • Should be easy to style the gallery in your own way – uses CSS classes and IDs.
  • The user can click on the main image to cycle through the gallery.
  • Uses jQuery for cross-browser hover fade effects.
  • Small JS footprint: 2854 bytes.
  • Outputs valid XHTML (unlike the default WordPress gallery!).

Screenshot of the plugin:

Screenshot of Bitvolution-image-galleria plugin

Click to enlarge

Demo of plugin: www.greekislandpropertyfinders.co.uk/what-we-are-finding.

Download the plugin from the WordPress.org plugin directory.

Screenshot of problem with too big tag

On this WordPress theme, the sidebar is quite small (only 220px) and the default WordPress tag cloud widget was producing tags that were clipped in a ugly manner. By default, the WordPress tag cloud widget has a maximum font size of 22px so I was looking for a way to reduce it.

Note: If you are not a theme editor, you might find it easier to just install a suitable tag cloud plugin, e.g. Configurable Tag Cloud (CTC).

The WordPress tag cloud widget already allows you to specify various options including the largest font size, e.g. <?php wp_tag_cloud('largest=18'); ?> so we only need to create a new widget that overrides the default widget and then unregister the default widget so there aren’t two widgets with the same name in the “Available Widgets” dashboard page. We can register our own widget using register_sidebar_widget and we can unregister the default tag cloud widget using unregister_widget('WP_Widget_Tag_Cloud');.

This is the code you need – put it in the functions.php file in your WordPress theme folder:

add_action("widgets_init", array('Tag_cloud_withLimitedFontSize', 'register'));

/** Widget - Override the default WordPress tag cloud BUT cap the largest font size to 18 (instead of 22)\
 because at 22 some tags don't fit in the sidebar. */
class Tag_cloud_withLimitedFontSize
{
  function widget($args){
    echo $args['before_widget'];
    echo $args['before_title'] . 'Tags' . $args['after_title'];
    echo wp_tag_cloud('largest=18');
    echo $args['after_widget'];
  }

  function register()
  {
    register_sidebar_widget('Tag Cloud', array('Tag_cloud_withLimitedFontSize', 'widget'));
    unregister_widget('WP_Widget_Tag_Cloud');
  }
}

If there’s a better way to do this, please let me know.

Microchip as a bug

A website that I was working on suddenly started crashing Firefox 3.6 on my PC (Ubuntu 9.10, 64bit). I’m talking a full out hang with 100% CPU usage and a frozen mouse and keyboard and the only way to recover is to remote login from a 2nd PC and kill the Firefox process.

I found the cause of the crash and it was a single line of recently added CSS code at the top of the websites stylesheet: body { opacity: 0.9999; }

So, if you run a website, be careful of non-100% opacity when it affects many elements. I have hosted a page that reproduces the issue and found a bug that tracks the issue: #279890. This CSS is also a problem on Windows – it causes text to blur horribly in IE 7 in some situations.

What is that CSS for anyway? Firefox 2.0 on Macs used to have a problem where text could dim or get bold or flicker when a animated effect that changed the opacity of an element was used. It was caused because the use of a opacity filter triggered the Gecko rendering engine to switch from the operating system’s method of anti-aliasing to its own internal method. Whenever opacity dropped below 100% the mode switched and resulted in a defect such as a flicker or blink. The fix was simple – all that was needed was to add body { -moz-opacity: 0.9999; } to the stylesheet because it would force Firefox to use a consistent text rendering method.

Hack == Bug

Wordpress LogoToday, I found out about a WordPress plugin called Elastic (http://elastictheme.org/, download link) which is a WYSIWYG theme editor for WordPress.

It looks like a very promising technology to make it easier to develop WordPress themes. I’m interested in re-useable modules so, if I develop something interesting for one client, I can re-use the same something for a different client with 1-click (therefore being able to quote them a reduced price). Plugins and widgets achieve this to some extent but Elastic aims to make the same possible at a more fundamental level.