<?php
namespace wcf\data\user\avatar;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Represents a default avatar.
public function getImageTag($size = null) {
if ($size === null) $size = $this->size;
- return '<img src="'.$this->getURL($size).'" style="width: '.$size.'px; height: '.$size.'px" alt="'.WCF::getLanguage()->get('wcf.user.avatar.alt').'" class="userAvatarImage" />';
+ return '<img src="'.StringUtil::encodeHTML($this->getURL($size)).'" style="width: '.$size.'px; height: '.$size.'px" alt="'.WCF::getLanguage()->get('wcf.user.avatar.alt').'" class="userAvatarImage" />';
}
/**
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\FileUtil;
+use wcf\util\StringUtil;
/**
* Represents a gravatar.
*/
public function getURL($size = null) {
if ($size === null) $size = $this->size;
+ else {
+ switch ($size) {
+ case 16:
+ case 24:
+ $size = 32;
+ break;
+ case 48:
+ $size = 96;
+ break;
+ }
+ }
if (!isset($this->url[$size])) {
// try to use cached gravatar
}
}
+ /**
+ * @see \wcf\data\user\avatar\IUserAvatar::getImageTag()
+ */
+ public function getImageTag($size = null) {
+ if ($size === null) $size = $this->size;
+
+ $retinaSize = null;
+ switch ($size) {
+ case 16:
+ $retinaSize = 32;
+ break;
+ case 24:
+ case 32:
+ case 48:
+ $retinaSize = 96;
+ break;
+ case 96:
+ $retinaSize = 128;
+ break;
+ }
+
+ return '<img src="'.StringUtil::encodeHTML($this->getURL($size)).'" '.($retinaSize !== null ? ('srcset="'.StringUtil::encodeHTML($this->getURL($retinaSize)).' 2x" ') : '').'style="width: '.$size.'px; height: '.$size.'px" alt="'.WCF::getLanguage()->get('wcf.user.avatar.alt').'" class="userAvatarImage" />';
+ }
+
/**
* @see \wcf\data\user\avatar\IUserAvatar::canCrop()
*/
* needed avatar thumbnail sizes
* @var array<integer>
*/
- public static $avatarThumbnailSizes = array(16, 24, 32, 48, 96, 128);
+ public static $avatarThumbnailSizes = array(32, 96, 128);
/**
* @see \wcf\data\DatabaseObject::$databaseTableName
* @return string
*/
public function getFilename($size = null) {
+ switch ($size) {
+ case 16:
+ case 24:
+ $size = 32;
+ break;
+ case 48:
+ $size = 96;
+ break;
+ }
+
return substr($this->fileHash, 0, 2) . '/' . ($this->avatarID) . '-' . $this->fileHash . ($size !== null ? ('-' . $size) : '') . '.' . $this->avatarExtension;
}
}
}
- return '<img src="'.StringUtil::encodeHTML($this->getURL($size)).'" style="width: '.$width.'px; height: '.$height.'px" alt="'.WCF::getLanguage()->get('wcf.user.avatar.alt').'" class="userAvatarImage" />';
+ $retinaSize = null;
+ switch ($size) {
+ case 16:
+ $retinaSize = 32;
+ break;
+ case 24:
+ case 32:
+ case 48:
+ $retinaSize = 96;
+ break;
+ case 96:
+ $retinaSize = 128;
+ break;
+ }
+
+ return '<img src="'.StringUtil::encodeHTML($this->getURL($size)).'" '.($retinaSize !== null ? ('srcset="'.StringUtil::encodeHTML($this->getURL($retinaSize)).' 2x" ') : '').'style="width: '.$width.'px; height: '.$height.'px" alt="'.WCF::getLanguage()->get('wcf.user.avatar.alt').'" class="userAvatarImage" />';
}
/**