Может кому пригодится, сделано на основе превью в Файловом менеджере, так что видимо будет работать только на версии когда появились миниатюры там 6.1.2, но могу ошибаться

bootstrap.php
// для информационных систем
Core_Event::attach('informationsystem_item.onCallPreview', array('Asmp_Preview', 'onCallPreview'));
// для интернет-магазина
Core_Event::attach('shop_item.onCallPreview', array('Asmp_Preview', 'onCallPreview'));
создаем /modules/asmp/preview.php
defined('HOSTCMS') || exit('HostCMS: access denied.');
class Asmp_Preview
{
static public function onCallPreview($object, $args)
{
$icon_file = NULL;
$oCurrentAlias = NULL;
if(get_class($object) == 'Informationsystem_Item_Model')
{
$oCurrentAlias = $object->Informationsystem->Site->getCurrentAlias();
}
elseif (get_class($object) == 'Shop_Item_Model')
{
$oCurrentAlias = $object->Shop->Site->getCurrentAlias();
}
if ($object->image_small && $oCurrentAlias)
{
$link = 'http://' . $oCurrentAlias->name . $object->getSmallFileHref();
$aExt = array('JPG', 'JPEG', 'GIF', 'PNG');
try
{
if (Core_File::isValidExtension($object->image_small, $aExt))
{
$sImgContent = NULL;
$filePath = $object->getSmallFilePath();
/// ------
$maxWidth = 50;
$maxHeight = 50;
$picsize = Core_Image::getImageSize($filePath);
if ($picsize)
{
$sourceX = $picsize['width'];
$sourceY = $picsize['height'];
/* Если размеры исходного файла больше максимальных, тогда масштабируем*/
if (($sourceX > $maxWidth || $sourceY > $maxHeight))
{
$destX = $sourceX;
$destY = $sourceY;
// Масштабируем сначала по X
if ($destX > $maxWidth && $maxWidth != 0)
{
$coefficient = $sourceY / $sourceX;
$destX = $maxWidth;
$destY = ceil($maxWidth * $coefficient);
}
// Масштабируем по Y
if ($destY > $maxHeight && $maxHeight != 0)
{
$coefficient = $sourceX / $sourceY;
$destX = ceil($maxHeight * $coefficient);
$destY = $maxHeight;
}
// в $destX и $destY теперь хранятся размеры оригинального изображения после уменьшения
// от них рассчитываем размеры для обрезания на втором шаге
$destX_step2 = $maxWidth;
// Масштабируем сначала по X
if ($destX > $maxWidth && $maxWidth != 0)
{
// Позиции, с которых необходимо вырезать
$src_x = ceil(($destX - $maxWidth) / 2);
}
else
{
$src_x = 0;
}
// Масштабируем по Y
if ($destY > $maxHeight && $maxHeight != 0)
{
$destY_step2 = $maxHeight;
$destX_step2 = $destX;
// Позиции, с которых необходимо вырезать
$src_y = ceil(($destY - $maxHeight) / 2);
}
else
{
$destY_step2 = $destY;
$src_y = 0;
}
$targetResourceStep1 = imagecreatetruecolor($destX, $destY);
$ext = Core_File::getExtension($object->image_small);
if ($ext == 'jpg' || $ext == 'jpeg')
{
$quality = JPG_QUALITY;
$sourceResource = imagecreatefromjpeg($filePath);
if ($sourceResource)
{
// Изменяем размер оригинальной картинки и копируем в созданую картинку
imagecopyresampled($targetResourceStep1, $sourceResource, 0, 0, 0, 0, $destX, $destY, $sourceX, $sourceY);
ob_start();
//imagejpeg($targetResourceStep1, $quality);
imagejpeg($targetResourceStep1);
$sImgContent = ob_get_clean();
imagedestroy($sourceResource);
}
}
elseif ($ext == 'png')
{
$sourceResource = imagecreatefrompng($filePath);
if ($sourceResource)
{
imagealphablending($targetResourceStep1, FALSE);
imagesavealpha($targetResourceStep1, TRUE);
imagecopyresized($targetResourceStep1, $sourceResource, 0, 0, 0, 0, $destX, $destY, $sourceX, $sourceY);
ob_start();
imagepng($targetResourceStep1);
$sImgContent = ob_get_clean();
imagedestroy($sourceResource);
}
}
elseif ($ext == 'gif')
{
$sourceResource = imagecreatefromgif($filePath);
if ($sourceResource)
{
Core_Image_Gd::setTransparency($targetResourceStep1, $sourceResource);
imagecopyresampled($targetResourceStep1, $sourceResource, 0, 0, 0, 0, $destX, $destY, $sourceX, $sourceY);
ob_start();
imagegif($targetResourceStep1);
$sImgContent = ob_get_clean();
imagedestroy($sourceResource);
}
}
else
{
imagedestroy($targetResourceStep1);
return FALSE;
}
imagedestroy($targetResourceStep1);
}
else
{
$sImgContent = Core_File::read($filePath);
}
$icon_file = "data:" . Core_Mime::getFileMime($filePath) . ";base64," . base64_encode($sImgContent);
}
}
}
catch (Exception $e) { }
if($icon_file)
{
$oCore_Html_Entity_Div = Core::factory('Core_Html_Entity_Div')
->add(
Core::factory('Core_Html_Entity_A')
->href($link)
->onclick("window.open('{$link}','','width=400,height=300,left='+(screen.availWidth/2-200)+',top='+(screen.availHeight/2-150)+'');return false;")
->target('_blank')
->add(
Core::factory('Core_Html_Entity_Img')
->src($icon_file)
)
);
$oCore_Html_Entity_Div->execute();
}
}
}
}
ну и в формах ЦА нужно вызвать метод
Preview