developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #993: function.gravatar.php

File function.gravatar.php, 1.4 KB (added by foxmask, 12 years ago)

le code du plugin Gravatar

Line 
1<?php
2/**
3 * @package     jelix
4 * @subpackage  jtpl_plugin
5 * @author      Olivier Demah
6 * @copyright  2009
7 * @link        http://www.jelix.org
8 * @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
9 */
10
11/**
12 * gravatar plugin :  write the url corresponding to the image of the gravatar account identified by the given email address
13 *
14 * @param jTpl $tpl template engine
15 * @param string $email account
16 * @param array $params parameters for :
17 *  1) the default avatar URL
18 *  2) the default size of the image
19 *  3) the username to be put in the "alt" attribute of the img
20 */
21function jtpl_function_html_gravatar($tpl, $email, $params=array()) {
22
23    // if no default url is given for the default gravatar,
24    // this will display the default Gravatar Image from gravatar.com
25    if ( ! array_key_exists('default',$params))
26        $params['default'] = null; 
27    if ( !array_key_exists('size',$params))
28        $params['size'] = 60;
29   
30    $gravatarUrl = "http://www.gravatar.com/avatar.php?";
31    $gravatarUrl .= "gravatar_id=".md5( strtolower($email) );
32    if ($params['default'] != null)
33        $gravatarUrl .= "&amp;default=".urlencode($params['default']);
34    $gravatarUrl .= "&amp;size=".$params['size'];
35
36    echo '<img src="'.$gravatarUrl. '" class="gravatar" alt="'.htmlentities($params['username']).'"/>';
37
38}