• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/ui/accessrights/avatar.php
  • Класс: BitrixMainUIAccessRightsAvatar
  • Вызов: Avatar::getSrc
static function getSrc($avatarId, $width = 58, $height = 58): ?string
{
	if(empty($avatarId))
	{
		return null;
	}

	$avatarId = (int) $avatarId;
	$key = $avatarId . " $width $height";

	if (!isset(self::$cache[$key]))
	{
		$src = false;
		if ($avatarId > 0)
		{

			$imageFile = CFile::getFileArray($avatarId);
			if ($imageFile !== false)
			{

				$fileTmp = CFile::resizeImageGet(
					$imageFile,
					array("width" => $width, "height" => $height),
					BX_RESIZE_IMAGE_EXACT,
					false
				);
				$src = $fileTmp["src"];
			}

			self::$cache[$key] = $src;
		}
	}

	return self::$cache[$key];
}