http://www.gravatar.com/avatar/ <email_hash>? s = <size> & r = <rating> & d = <default><email_hash> - MD5 hash from a lower-case e-mail address with no spaces at the beginning and end;
<? php
/ *
* Smarty plugin
* ------------------------------------------------- ------------
* File: function.gravatar.php
* Type: function
* Name: gravatar
* Purpose: Build a URL for Gravatar
* ------------------------------------------------- ------------
* /
function smarty_function_gravatar ($ params )
{
$ url = 'http://www.gravatar.com/avatar/' ;
if (empty ($ params [ 'email' ])) {
$ params [ 'email' ] = '' ;
}
$ url. = md5 (strtolower (trim ($ params [ 'email' ])));
')
$ firstparam = true ;
if (isset ($ params [ 'size' ])) {
$ url. = '? s =' . $ params [ 'size' ];
$ firstparam = false ;
}
if (isset ($ params [ 'rating' ])) {
$ url. = ($ firstparam)? '?' : '&' ;
$ url. = 'r =' . $ params [ 'rating' ];
$ firstparam = false ;
}
if (isset ($ params [ 'default' ])) {
$ url. = ($ firstparam)? '?' : '&' ;
$ url. = 'd =' .urlencode ($ params [ 'default' ]);
}
return $ url;
}
?>
* This source code was highlighted with Source Code Highlighter .
< img src = "{gravatar email='my@email.com '}" alt = "Gravatar" />
< img src = "{gravatar email='my@email.com 'size = '40'}" alt = "Gravatar" />
< img src = "{gravatar email='my@email.com 'rating =' g '
default = 'http: //www.example.com/avatar.jpg'} " alt =" Gravatar " />
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/40336/
All Articles