• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/photoresizer.php
  • Класс: BitrixSaleTradingPlatformVkPhotoResizer
  • Вызов: PhotoResizer::buildPictureUrl
static function buildPictureUrl($src, $domain = '')
{
	if ($domain == '')
	{
//			get different variants of domain URL, because in diff site some variants not work
		$server = Application::getInstance()->getContext()->getServer();
		if ($host = $server->getHttpHost())
		{
			$domain = strtok($host, ':');
		}
		elseif ($name = $server->getServerName())
		{
			$domain = strtok($name, ':');
		}
		else
		{
			$domain = strtok(SITE_SERVER_NAME, ':');
		}
	}
	
	$protocol = CMain::IsHTTPS() ? "https://" : "http://";
	// relative path by '/'
	if (mb_substr($src, 0, 1) == "/")
	{
		$strFile = $protocol . $domain . implode("/", array_map("rawurlencode", explode("/", $src)));
	}
	// full path
	elseif (preg_match("/^(http|https):\/\/(.*?)\/(.*)$/", $src, $match))
	{
		$strFile = $protocol . $match[2] . '/' . implode("/", array_map("rawurlencode", explode("/", $match[3])));
	}
	// default
	else
	{
		$strFile = $src;
	}
	
	return $strFile;
}