Skip to content

Commit

Permalink
✨ 增加自定义Gravatar源支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Feb 5, 2023
1 parent e99e0f5 commit dd5486d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions inc/fun/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ function pk_post_style_list()
} else if ($type == 'v2ex') {
add_filter('get_avatar', 'v2ex_ssl_avatar');
add_filter('get_avatar_url', 'v2ex_ssl_avatar');
} else if($type=='custom'){
add_filter('get_avatar', 'pk_custom_avatar');
add_filter('get_avatar_url', 'pk_custom_avatar');
}
}
//评论者链接
Expand Down
5 changes: 5 additions & 0 deletions inc/fun/opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ function v2ex_ssl_avatar($avatar)
return str_replace("http://", "https://", str_replace("/avatar", "/gravatar", str_replace($gravatar_urls, 'cdn.v2ex.com', $avatar)));
}

function pk_custom_avatar($avatar){
global $gravatar_urls;
return str_replace($gravatar_urls, pk_get_option('gravatar_custom_url'), $avatar);
}

//评论回复邮件通知
function comment_mail_notify($comment_id)
{
Expand Down
10 changes: 10 additions & 0 deletions inc/setting/options/OptionBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,19 @@ function get_fields(): array
[
'value' => 'loli',
'label' => 'loli.net'
],
[
'value' => 'custom',
'label' => __('自定义', PUOCK)
]
],
],
[
'id'=>'gravatar_custom_url',
'label'=>__('自定义Gravatar源', PUOCK),
'tips'=>__('例如:',PUOCK).'<code>gravatar.example.com</code>',
'showRefId'=>'func:(function(args){return args.data.gravatar_url==="custom"})(args)'
],
[
'id' => 'post_reward',
'label' => __('文章赞赏', PUOCK),
Expand Down

0 comments on commit dd5486d

Please sign in to comment.