avatar URL function
This commit is contained in:
parent
3b89acc458
commit
4e5444e217
1 changed files with 12 additions and 2 deletions
|
@ -213,6 +213,16 @@ class User
|
||||||
* a local file, a remote file, a gravatar, a something else, etc.
|
* a local file, a remote file, a gravatar, a something else, etc.
|
||||||
*/
|
*/
|
||||||
public function get_avatar_html(): string
|
public function get_avatar_html(): string
|
||||||
|
{
|
||||||
|
$url = $this->get_avatar_url();
|
||||||
|
if (!empty($url)) {
|
||||||
|
return "<img alt='avatar' class=\"avatar gravatar\" src=\"$url\">";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Field(name: "avatar_url")]
|
||||||
|
public function get_avatar_url(): ?string
|
||||||
{
|
{
|
||||||
// FIXME: configurable
|
// FIXME: configurable
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -223,10 +233,10 @@ class User
|
||||||
$d = urlencode($config->get_string("avatar_gravatar_default"));
|
$d = urlencode($config->get_string("avatar_gravatar_default"));
|
||||||
$r = $config->get_string("avatar_gravatar_rating");
|
$r = $config->get_string("avatar_gravatar_rating");
|
||||||
$cb = date("Y-m-d");
|
$cb = date("Y-m-d");
|
||||||
return "<img alt='avatar' class=\"avatar gravatar\" src=\"https://www.gravatar.com/avatar/$hash.jpg?s=$s&d=$d&r=$r&cacheBreak=$cb\">";
|
return "https://www.gravatar.com/avatar/$hash.jpg?s=$s&d=$d&r=$r&cacheBreak=$cb";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue