Skip to content

Instantly share code, notes, and snippets.

@wdssmq
Created July 17, 2024 06:22
Show Gist options
  • Save wdssmq/2cf226273ef034e005ed452b44ed5cbb to your computer and use it in GitHub Desktop.
Save wdssmq/2cf226273ef034e005ed452b44ed5cbb to your computer and use it in GitHub Desktop.
tpure_MemberAvatar
<?php
// 头像优先级
function tpure_MemberAvatar($member, $email = null)
{
global $zbp;
// 先拿到系统头像,包括其他插件返回的
$avatar = $member->Avatar;
// 判断是否包含 zb_users/avatar/0.png
if (strpos($avatar, "zb_users/avatar/0.png") === false) {
return $avatar;
}
$targetEmail = isset($email) ? $email : $member->Email;
// 判断是否指定了头像
if ($member->Metas->memberimg) {
$avatar = $member->Metas->memberimg;
} elseif ($targetEmail) {
preg_match_all('/((\d)*)@qq.com/', $email, $vai);
// 如果匹配到 QQ 号
if (isset($vai[1][0])) {
$qq = $vai[1][0];
$avatar = "https://q.qlogo.cn/headimg_dl?dst_uin={$qq}&spec=100";
}
}
return $avatar;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment