Always return absolute URLs for avatars

This commit is contained in:
Alma Armas 2020-09-29 13:03:55 -07:00
parent a67241c5da
commit a608ebc1a7
2 changed files with 10 additions and 5 deletions

View file

@ -40,9 +40,11 @@ class Club extends RowModel
function getAvatarUrl(): string
{
$avPhoto = $this->getAvatarPhoto();
$serverUrl = "http" . ($_SERVER["HTTPS"] === "on" ? "s" : "") . "://";
$serverUrl .= $_SERVER["HTTP_HOST"];
$avPhoto = $this->getAvatarPhoto();
return is_null($avPhoto) ? "/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURL();
return is_null($avPhoto) ? "$serverUrl/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURL();
}
function getAvatarLink(): string

View file

@ -94,14 +94,17 @@ class User extends RowModel
function getAvatarUrl(): string
{
$serverUrl = "http" . ($_SERVER["HTTPS"] === "on" ? "s" : "") . "://";
$serverUrl .= $_SERVER["HTTP_HOST"];
if($this->getRecord()->deleted)
return "/assets/packages/static/openvk/img/camera_200.png";
return "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
else if($this->isBanned())
return "/assets/packages/static/openvk/img/banned.jpg";
return "$serverUrl/assets/packages/static/openvk/img/banned.jpg";
$avPhoto = $this->getAvatarPhoto();
if(is_null($avPhoto))
return "/assets/packages/static/openvk/img/camera_200.png";
return "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
else
return $avPhoto->getURL();
}