CCrmProductFile::GetImgHtml

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProductFile
  4. GetImgHtml
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product_file.php
  • Класс: \CCrmProductFile
  • Вызов: CCrmProductFile::GetImgHtml
function GetImgHtml($params = array())
{
	$max_width = 0;
	$max_height = 0;

	if(is_array($params))
	{
		if(isset($params['max_width']))
			$max_width = intval($params['max_width']);
		if(isset($params['max_height']))
			$max_height = intval($params['max_height']);
	}

	if(is_array($this->_file))
	{
		$intWidth = $this->_width;
		$intHeight = $this->_height;
		if($intWidth > 0 && $intHeight > 0 && $max_width > 0 && $max_height > 0)
		{
			if($intWidth > $max_width || $intHeight > $max_height)
			{
				$coeff = ($intWidth/$max_width > $intHeight/$max_height? $intWidth/$max_width : $intHeight/$max_height);
				$intWidth = intval(roundEx($intWidth/$coeff));
				$intHeight= intval(roundEx($intHeight/$coeff));
			}
		}
		$file = new CFile();
		$arResizeInfo = $file->ResizeImageGet(
			$this->_file_id,
			array('width' => $intWidth, 'height' => $intHeight),
			BX_RESIZE_IMAGE_PROPORTIONAL,
			false
		);
		$src = $arResizeInfo['src'];
		$html = ' $value)
				if(preg_match('/^[a-zA-Z-]+$/', $name))
					$html .= ' '.$name.'="'.htmlspecialcharsbx($value).'"';
		}
		$html .= '/>';
		return $html;
	}
	else
	{
		return '';
	}
}

Добавить комментарий