From 4e5444e217297f044f366c3d5be2886cc2b7c14d Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 8 Feb 2023 01:28:22 +0000 Subject: [PATCH] avatar URL function --- core/user.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/user.php b/core/user.php index 48394723..73722add 100644 --- a/core/user.php +++ b/core/user.php @@ -213,6 +213,16 @@ class User * a local file, a remote file, a gravatar, a something else, etc. */ public function get_avatar_html(): string + { + $url = $this->get_avatar_url(); + if (!empty($url)) { + return "avatar"; + } + return ""; + } + + #[Field(name: "avatar_url")] + public function get_avatar_url(): ?string { // FIXME: configurable global $config; @@ -223,10 +233,10 @@ class User $d = urlencode($config->get_string("avatar_gravatar_default")); $r = $config->get_string("avatar_gravatar_rating"); $cb = date("Y-m-d"); - return "avatar"; + return "https://www.gravatar.com/avatar/$hash.jpg?s=$s&d=$d&r=$r&cacheBreak=$cb"; } } - return ""; + return null; } /**