WordPress: Gravatar Shortcode Plugin

This is a simple plugin that just lets you use a shortcode in your WordPress Pages or Posts to quickly and easily insert a Gravatar. Once you install it, all you need to do is to use the new shortcode anywhere in a Post or Page.

Installation

  1. Download WP-Gravatar-Shortcode from the official WordPress plugins repository
  2. Unzip it to your /wp-content/plugins/ directory
  3. Activate the plugin in wp-admin under Plugins

Usage

In any of your Posts or Pages, you can now use the Gravatar shortcode, which at its simplest looks like this (with NO spaces at the beginning and ending):

[ gravatar email="email@domain.com" ]

When a Page/Post containing this shortcode is published, the code will be replaced with the Gravatar associated with the email specified. There are a number of additional attributes you can include to modify the Gravatar which is displayed, as discussed in the next section.

Supported Attributes

In addition to email=””, you can also include the following attributes within the shortcode for extra formatting etc:

  • email: the email address to display the Gravatar for
  • size: a number (e.g. 60) representing the pixel size of the Gravatar to display (they are square)
  • rating: a letter restricting the maxiumum rating of Gravatar to display (g, pg, r, x)
  • default: the default image to use if there isn’t one associated with this email address (otherwise it will use the Gravatar.com default)
  • alt: the “alt” attribute to apply to the img tag produced
  • title: title attribute for the img tag
  • align: align attribute for the img, should be left, right, absmiddle, baseline etc
  • style: custom style attribute (e.g. ‘margin: 5px; border: solid 1px #000;’)
  • class: add a class to the img tag
  • id: add an id to the img tag for specific styling/DOM manipulation.
  • border: adjust the border attribute for the img

For example:

[ gravatar email="email@domain.com" size="100" alt="My Amazing Gravatar" class="user-picture" ]