From e81083461a001a9b75226c54e8f65764d9e8e075 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 12 Jun 2023 20:33:46 +0200 Subject: [PATCH] Support png avatars --- src/Profile.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Profile.php b/src/Profile.php index ca204ac..e120546 100644 --- a/src/Profile.php +++ b/src/Profile.php @@ -4,6 +4,8 @@ */ class Profile { + protected string $avatarDir; + public int $id; public string $hwId; public string $sessionId; @@ -16,6 +18,11 @@ class Profile public string $created_at; + public function __construct() + { + $this->avatarDir = dirname(__FILE__) . '/../www/resources/avatars/'; + } + public function complete(): bool { return $this->gamerTag !== null; @@ -26,8 +33,15 @@ class Profile if (strpos($this->avatar, '://')) { return $this->avatar; } + + if (file_exists($this->avatarDir . $this->avatar . '.large.jpg')) { + $ext = 'jpg'; + } else { + $ext = 'png'; + } + return 'http://l2.gamestickservices.net/resources/avatars/' - . $this->avatar . '.large.jpg'; + . $this->avatar . '.large.' . $ext; } public function getAvatarSmallUrl(): string @@ -35,7 +49,14 @@ class Profile if (strpos($this->avatar, '://')) { return $this->avatar; } + + if (file_exists($this->avatarDir . $this->avatar . '.small.jpg')) { + $ext = 'jpg'; + } else { + $ext = 'png'; + } + return 'http://l2.gamestickservices.net/resources/avatars/' - . $this->avatar . '.small.jpg'; + . $this->avatar . '.small.' . $ext; } } -- 2.30.2