Created
July 17, 2024 06:22
-
-
Save wdssmq/2cf226273ef034e005ed452b44ed5cbb to your computer and use it in GitHub Desktop.
tpure_MemberAvatar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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