- Модуль: subscribe
- Путь к файлу: ~/bitrix/modules/subscribe/classes/general/posting.php
- Класс: CMailTools
- Вызов: CMailTools::__replace_img
function __replace_img($matches)
{
$io = CBXVirtualIo::GetInstance();
$src = $matches[3];
if($src == "")
return $matches[0];
if(array_key_exists($src, $this->aMatches))
{
$uid = $this->aMatches[$src]["ID"];
return $matches[1].$matches[2]."cid:".$uid.$matches[4].$matches[5];
}
$filePath = $io->GetPhysicalName($_SERVER["DOCUMENT_ROOT"].$src);
if(!file_exists($filePath))
return $matches[0];
if (
$this->maxFileSize > 0
&& filesize($filePath) > $this->maxFileSize
)
return $matches[0];
$aImage = CFile::GetImageSize($filePath, true);
if (!is_array($aImage))
return $matches[0];
if (function_exists("image_type_to_mime_type"))
$contentType = image_type_to_mime_type($aImage[2]);
else
$contentType = CMailTools::ImageTypeToMimeType($aImage[2]);
$uid = uniqid(md5($src));
$this->aMatches[$src] = array(
"SRC" => $src,
"PATH" => $filePath,
"CONTENT_TYPE" => $contentType,
"DEST" => bx_basename($src),
"ID" => $uid,
);
return $matches[1].$matches[2]."cid:".$uid.$matches[4].$matches[5];
}