Skip to content

Instantly share code, notes, and snippets.

@fwartner
Created June 24, 2014 16:24
Show Gist options
  • Save fwartner/26c3ec4ed04509a299e5 to your computer and use it in GitHub Desktop.
Save fwartner/26c3ec4ed04509a299e5 to your computer and use it in GitHub Desktop.
Gravatar Image-Helper for CodeIgniter
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('get_gravatar')) {
function get_gravatar( $email, $s, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
if ( $img ) {
$url = '<img src="' . $url . '"';
foreach ( $atts as $key => $val )
$url .= ' ' . $key . '="' . $val . '"';
$url .= ' />';
}
return $url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment