diff options
| author | Eltrac Koalar <hi@guhub.cn> | 2022-09-24 00:04:48 +0800 |
|---|---|---|
| committer | Eltrac Koalar <hi@guhub.cn> | 2022-09-24 00:04:48 +0800 |
| commit | 52483e20425574644435d1d5c3b2e52e4706d17d (patch) | |
| tree | 6ae096edf1a2ed36a7dad435eac23af5bf73a660 /libs/Comments.php | |
| parent | 77a08c7f285444250adb87c6ac3aaed5a8d5f16e (diff) | |
:koala: Perf: 评论区头像支持懒加载
Diffstat (limited to 'libs/Comments.php')
| -rw-r--r-- | libs/Comments.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libs/Comments.php b/libs/Comments.php index 4dcb4ce..fcdb77e 100644 --- a/libs/Comments.php +++ b/libs/Comments.php @@ -34,4 +34,32 @@ Class Comments { echo ""; } } + + /** + * 获取 Gravatar 头像链接 + */ + public static function gravatar($email, int $size = 100, int $useCDN = NULL) + { + //MD5 EMail + $email = md5($email); + $avatar = 'https://cn.gravatar.com/avatar/' . $email . '?s=' . $size; + + return $avatar; + } + + /** + * 获取评论者头像 + */ + public static function getAvatar($email, int $size = 100) + { + //Hash + $email_hash = md5(strtolower($email)); + + //EMail + $email = strtolower($email); + + $avatar = self::gravatar($email, $size); + + return $avatar; + } }
\ No newline at end of file |
