• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/textparser.php
  • Класс: CTextParser
  • Вызов: CTextParser::convertVideo
public function convertVideo($matches)
{
	$params = $matches[1];
	$path = $matches[2];

	if ($path == '')
	{
		return '';
	}

	$width = '';
	$height = '';
	$preview = '';
	$provider = '';
	$type = '';
	preg_match("/width=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $params, $width);
	preg_match("/height=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $params, $height);

	preg_match("/preview='([^']+)'/is" . BX_UTF_PCRE_MODIFIER, $params, $preview);
	if (empty($preview))
	{
		preg_match("/preview="([^"]+)"/is" . BX_UTF_PCRE_MODIFIER, $params, $preview);
	}

	preg_match("/type=(YOUTUBE|RUTUBE|VIMEO|VK|FACEBOOK|INSTAGRAM)/is" . BX_UTF_PCRE_MODIFIER, $params, $provider);
	preg_match("/mimetype='([^']+)'/is" . BX_UTF_PCRE_MODIFIER, $params, $type);

	$width = intval($width[1]);
	$width = ($width > 0 ? $width : 400);
	$height = intval($height[1]);
	$height = ($height > 0 ? $height : 300);
	$preview = trim($preview[1]);
	$preview = ($preview != '' ? $preview : '');
	$provider = isset($provider[1])? mb_strtoupper(trim($provider[1])) : '';
	$type = trim($type[1]);

	$arFields = [
		'PATH' => $path,
		'WIDTH' => $width,
		'HEIGHT' => $height,
		'PREVIEW' => $preview,
		'TYPE' => $provider,
		'MIME_TYPE' => $type,
		'PARSER_OBJECT' => $this,
	];

	foreach (GetModuleEvents('main', 'TextParserVideoConvert', true) as $arEvent)
	{
		ExecuteModuleEventEx($arEvent, [&$arFields, &$this]);
	}

	$video = $this->convert_video($arFields);

	return $this->defended_tags($video);
}