Enable Gravatar for Kanboard users and select your own default Avatar.
Download and use it for your project on Github
![](https://res.cloudinary.com/read-cv/image/upload/c_limit,h_2048,w_2048/v1/1/pages/x1qbBjv9EsW6JIFNfdN1uWtqpuZ2/kanboard-gravatar/3cbb8116-809b-417d-b9b5-1a033feb0004.png?_a=DATAdtfiZAA0)
This is just the main file preview of the plugin
<?php
namespace Kanboard\Plugin\Gravatar;
use Kanboard\Core\Base;
use Kanboard\Core\User\Avatar\AvatarProviderInterface;
/**
* Gravatar Avatar Provider
*
* @package avatar
* @author Frederic Guillot & Updated by Alexandru Șerban
*/
class GravatarProvider extends Base implements AvatarProviderInterface
{
/**
* Render avatar html
*
* @access public
* @param array $user
* @param int $size
* @return string
*/
public function render(array $user, $size)
{
// Check if the user has a Gravatar email
if ($this->hasGravatarEmail($user['email'])) {
// Use Gravatar
$url = sprintf('https://www.gravatar.com/avatar/%s?s=%d', md5(strtolower($user['email'])), $size);
} else {
// Use the default avatar image
$defaultAvatarUrl = '/plugins/Gravatar/Avatar.png'; // Specify the path to your default avatar image
$url = $defaultAvatarUrl;
}
$title = $this->helper->text->e($user['name'] ?: $user['username']);
return '<img src="'.$url.'" alt="'.$title.'" title="'.$title.'" width="'.$size.'" height="'.$size.'">';
}
/**
* Determine if the provider is active
*
* @access public
* @param array $user
* @return boolean
*/
public function isActive(array $user)
{
return true; // The provider is always active
}
/**
* Check if the email has a Gravatar associated with it
*
* @param string $email
* @return boolean
*/
private function hasGravatarEmail($email)
{
$hash = md5(strtolower($email));
$gravatarUrl = "https://www.gravatar.com/avatar/$hash?d=404"; // Use "d=404" to check if a Gravatar image exists
$headers = get_headers($gravatarUrl);
return strpos($headers[0], '200') !== false;
}
}