diff options
| author | LiCaoZ <admin@licaoz.com> | 2023-07-21 00:21:13 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-21 00:21:13 +0800 |
| commit | f334479db34f7133832a8f15077eef27fdfe89af (patch) | |
| tree | 6ff466c356b5bb2d166243407ed6067b4136d5d4 | |
| parent | 3aa14a11d299ae6c30cc159463454763232296c8 (diff) | |
feat: 支持自定义 Gravatar CDN (#35) (#37)
* feat: Gravatar 支持自订镜像
* feat: 支持自定义 Gravatar CDN (#35)
| -rw-r--r-- | libs/Comments.php | 9 | ||||
| -rw-r--r-- | libs/Options.php | 5 |
2 files changed, 13 insertions, 1 deletions
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(' + <p class="description">在此处填入你期望使用的 Gravatar CDN 链接,形如 <code>https://cravatar.cn/avatar/</code></p> + <p class="description">留空则使用 <a rel="nofollow noreferrer" target="_blank" href="https://cravatar.cn/">Cravatar</a></p>')); + $form->addInput($CustomGravatarCDN); /** * 附加功能 |
