composer require yzalis/identicon

使用

/**
 * 获取头像
 */ 
public function getAvatar($uid = '')
{
    $identicon = new \Identicon\Identicon();
    if ($uid) {
        $result = $identicon->getImageData($uid);
    } else {
        $result = $identicon->getImageData(mt_rand(1000,9999));
    }
    $uploudUtil = new UploadUtil();
    $cdn_result = $uploudUtil->uploadCdn($result, 'suncode');
    if ($cdn_result['errno'] == 0) {
        return $cdn_result['save_name'];
    } else {
        return false;
    }
}

yzalis/identicon 像素头像

设置默认头像的时候,可以用到这个功能。

相关文章:

  • 2021-11-21
  • 2022-02-14
  • 2021-12-23
  • 2022-01-01
  • 2021-06-04
  • 2021-12-03
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2021-07-31
相关资源
相似解决方案