Skip to content

Commit

Permalink
fix: Allow overwrite of default avatar in comments. (#2786)
Browse files Browse the repository at this point in the history
fixes #2468
  • Loading branch information
Levdbas committed Feb 24, 2024
1 parent b347677 commit 9c6e0e3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Comment.php
Expand Up @@ -252,6 +252,10 @@ public function avatar($size = 92, $default = '')
return $args['url'];
}

if (isset($args['default'])) {
$default = $args['default'];
}

$email_hash = '';
if (!empty($email)) {
$email_hash = \md5(\strtolower(\trim($email)));
Expand Down Expand Up @@ -609,11 +613,23 @@ protected function avatar_default($default, $email, $size, $host)
*/
protected function avatar_out($default, $host, $email_hash, $size)
{
$out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . \urlencode($default);
$out = $host . '/avatar/' . $email_hash;
$rating = \get_option('avatar_rating');

$url_args = [
's' => $size,
'd' => $default,
];

if (!empty($rating)) {
$out .= '&r=' . $rating;
$url_args['r'] = $rating;
}

$out = \add_query_arg(
\rawurlencode_deep(\array_filter($url_args)),
$out
);

return \str_replace('&', '&', \esc_url($out));
}
}

0 comments on commit 9c6e0e3

Please sign in to comment.