|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Tue Jan 11, 2011 12:32 pm Post subject: Gravatar - Easiest plugin |
|
|
This is a gravatar plugin: You just pass an email address to this, and it will give you a gravatar photo of it. Note: If the person (whose email you are showing) has not registered for gravatar, there appears a default [ G ] icon.
Usage: {$email|gravatar}
File: modifier.gravatar.php
I have put the links to original inspiring codes to create my non interactive version of gravatar plugin.
Code: |
<?php
# http://www.marvinmarcelo.com/smarty-gravatar-plugin/
/**
* Gravatar
*
* @link http://www.marvinmarcelo.com
*
* @param array $params
* @param Smarty $smarty
*/
function smarty_modifier_gravatar($email='')
{
/**
* constant $gravatar_host
*/
$gravatar_host = "http://www.gravatar.com/avatar/";
/**
* @link http://en.gravatar.com/site/implement/url
*/
$hash = strtolower(md5(trim($email)));
$src = $gravatar_host . $hash . ".jpg?";
$size = 60;
$src .= "s={$size}";
$default = "identicon";
$src .= "d={$default}";
$rating = "G";
$src .= "r={$rating}";
$extras = "";
return "<img src=\"$src\" />";
}
?>
|
Useful? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|