From f334479db34f7133832a8f15077eef27fdfe89af Mon Sep 17 00:00:00 2001 From: LiCaoZ Date: Fri, 21 Jul 2023 00:21:13 +0800 Subject: =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=20Gravatar=20CDN=20(#35)=20(#37)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Gravatar 支持自订镜像 * feat: 支持自定义 Gravatar CDN (#35) --- libs/Comments.php | 9 ++++++++- libs/Options.php | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/Comments.php b/libs/Comments.php index 52a7c6a..96c03f3 100644 --- a/libs/Comments.php +++ b/libs/Comments.php @@ -42,7 +42,14 @@ Class Comments { { //MD5 EMail $email = md5($email); - $avatar = 'https://cravatar.cn/avatar/' . $email . '?s=' . $size; + + // 如果配置了 CustomGravatarCDN,则用 CustomGravatarCDN 拼接 + if (Helper::options()->CustomGravatarCDN) { + $avatar = Helper::options()->CustomGravatarCDN . $email . '?s=' . $size; + } // 否则,使用 Cravatar + else { + $avatar = 'https://cravatar.cn/avatar/' . $email . '?s=' . $size; + } return $avatar; } diff --git a/libs/Options.php b/libs/Options.php index d8394df..06aadcb 100644 --- a/libs/Options.php +++ b/libs/Options.php @@ -90,6 +90,11 @@ function themeConfig($form) { ') ); $form->addInput($categoryNav->addRule('required', _t('此处必须设置'))); + // Gravatar CDN + $CustomGravatarCDN = new Typecho_Widget_Helper_Form_Element_Text('CustomGravatarCDN', NULL, NULL, _t('自定义评论头像 Gravatar CDN'), _t(' +

在此处填入你期望使用的 Gravatar CDN 链接,形如 https://cravatar.cn/avatar/

+

留空则使用 Cravatar

')); + $form->addInput($CustomGravatarCDN); /** * 附加功能 -- cgit v1.2.3