- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/textparser.php
- Класс: CTextParser
- Вызов: CTextParser::convert_image_tag
public function convert_image_tag($url = '', $params = '')
{
$url = trim($url);
if ($url == '')
{
return '';
}
preg_match("/width=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $params, $width);
preg_match("/height=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $params, $height);
$width = intval($width[1]);
$height = intval($height[1]);
$bErrorIMG = false;
if (!preg_match("/^(http|https|ftp|\/)/i" . BX_UTF_PCRE_MODIFIER, $url))
{
$bErrorIMG = true;
}
$url = htmlspecialcharsbx($url);
if ($bErrorIMG)
{
return '[img]' . $url . '[/img]';
}
$strPar = '';
if ($width > 0)
{
if ($width > $this->imageWidth)
{
$height = intval($height * ($this->imageWidth / $width));
$width = $this->imageWidth;
}
}
if ($height > 0)
{
if ($height > $this->imageHeight)
{
$width = intval($width * ($this->imageHeight / $height));
$height = $this->imageHeight;
}
}
if ($width > 0)
{
$strPar = " width="" . $width . """;
}
if ($height > 0)
{
$strPar .= " height="" . $height . """;
}
$serverName = htmlspecialcharsbx($this->serverName);
$image = '
';
if ($this->serverName == '' || preg_match("/^(http|https|ftp):\/\//i" . BX_UTF_PCRE_MODIFIER, $url))
{
$image = '
';
}
return $this->defended_tags($image);
}