# Gravatar View Helper

The `Gravatar` view helper is used to received avatars from Gravatar's service.

## Basic Usage of Gravatar View Helper

    // From a view script (using XHTML DOCTYPE):
    echo $this->gravatar('example@example.com');

    /* results in the following output:
        <img src="http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=80&d=mm&r=g" />
     */

Of course we can configure this helper. We can change height of image (by default it is 80px), and add CSS class or other attributes to image tag. The above simply shows the most basic usage.

## Use a valid email address!

The email address you provide the helper should be valid. This class does not validate the address (only the rating parameter). It is recommended to validate your email address within your model layer.

## Advanced Usage of Gravatar View Helper

There are several ways to configure the returned gravatar. In most cases, you may either pass an array of options as a second argument to the helper, or call methods on the returned object in order to configure it.

- The `img_size` option can be used to specify an alternate height; alternately, call `setImgSize()`.

- The `secure` option can be used to force usage of SSL in the returned image URI by passing a boolean `true` value (or disabling SSL usage by passing `false`). Alternately, call the `setSecure()` method. (By default, the setting follows the same security as the current page request.)

- To add attributes to the image, pass an array of key/value pairs as the third argument to the helper, or call the `setAttribs()` method.

    // Within the view script (using HTML DOCTYPE)
    echo $this->gravatar('example@example.com',
        array('imgSize' => 90, 'defaultImg' => 'monsterid', 'secure' => true),
        array('class' => 'avatar', 'title' => 'Title for this image')
    );

    // Or use mutator methods
    $this->gravatar()
         ->setEmail('example@example.com')
         ->setImgSize(90)
         ->setDefaultImg(Zend_View_Helper_Gravatar::DEFAULT_MONSTERID)
         ->setSecure(true)
         ->setAttribs(array('class' => 'avatar', 'title' => 'Title for this image'));

    /* Both generate the following output:
    <img class="avatar" title="Title for this image"
        src="https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=90&d=monsterid&r=g" >
     */

## Options

### Zend_Service_Gravatar Options

img_size

  An integer describing the height of the avatar, in pixels; defaults to "80".

default_img

  Image to return if the gravatar service is unable to match the email address provided. Defaults to "mm", the "mystery man" image.

rating

  Audience rating to confine returned images to. Defaults to "g"; may be one of "g", "pg", "r", or "x", in order of least offensive to most offensive.

secure

  Whether or not to load the image via an SSL connection. Defaults to the what is detected from the current request.