• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/mail/mail.php
  • Класс: BitrixMainMailMail
  • Вызов: Mail::getReplacedImageSrc
protected function getReplacedImageSrc($matches)
{
	$src = $matches[3];
	if($src == "")
	{
		return $matches[0];
	}

	$srcTrimmed = trim($src);
	if(mb_substr($srcTrimmed, 0, 2) == "//")
	{
		$src = $this->trackLinkProtocol . ":" . $srcTrimmed;
	}
	else if(mb_substr($srcTrimmed, 0, 1) == "/")
	{
		$srcModified = false;
		if(!empty($this->attachment))
		{
			$io = CBXVirtualIo::GetInstance();
			$filePath = $io->GetPhysicalName(Application::getDocumentRoot().$srcTrimmed);
			foreach($this->attachment as $attachIndex => $attach)
			{
				if($filePath == $attach['PATH'])
				{
					$this->attachment[$attachIndex]['RELATED'] = true;
					$src = "cid:".$attach['ID'];
					$srcModified = true;
					break;
				}
			}
		}

		if(!$srcModified)
		{
			$src = $this->trackLinkProtocol . "://".$this->settingServerName . $srcTrimmed;
		}
	}

	$add = '';
	if (mb_stripos($matches[0], ']*?\s+alt\s*=[^>]+>/is", $matches[0]))
	{
		$add = ' alt="" ';
	}

	return $matches[1] . $matches[2] . $src . $matches[4] . $add . $matches[5];
}