Create a gist now

Instantly share code, notes, and snippets.

Simple zend view helper for gravatar images.
<?php
/**
* @author Benjamin Borowski <ben.borowski@typeoneerror.com>
* @copyright Copyright (c) Typeoneerror Studios http://typeoneerror.com
* @version $Id: Gravatar.php 256 2009-11-06 02:46:32Z ben $
* @category Typeoneerror
* @package View
* @subpackage Helper
*/
/**
* Helper for rendering gravatar urls.
*
* @author Benjamin Borowski <ben.borowski@typeoneerror.com>
* @copyright Copyright (c) Typeoneerror Studios http://typeoneerror.com
* @version $Id: Gravatar.php 256 2009-11-06 02:46:32Z ben $
* @category Typeoneerror
* @package View
* @subpackage Helper
*/
class Typeoneerror_View_Helper_Gravatar extends Zend_View_Helper_Abstract
{
/**
* Compile a gravatar url.
*
* @param string $email User's email.
* @param int $size Size of avatar (it's squared).
* @param string $rating Rating of avatar.
* @param string $default Image style to show if no avatar found.
*
* @return string A gravatar url.
*
* @see http://en.gravatar.com/site/implement/url
*/
public function gravatar($email, $size = 80, $rating = "g", $default = "default")
{
$url = "http://www.gravatar.com/avatar/";
$url .= md5(strtolower($email));
$url .= "?s={$size}&amp;r={$rating}&amp;d={$default}";
return $url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment