Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Gravatar - Easiest plugin

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Tue Jan 11, 2011 12:32 pm    Post subject: Gravatar - Easiest plugin Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP