This repository was archived by the owner on Sep 13, 2024. It is now read-only.
This repository was archived by the owner on Sep 13, 2024. It is now read-only.
[bug] max-width / max-height parameters specified in MultiImage UItype are not supported #16476
Open
Description
Hi,
getTextParserDisplayValue public function in modules/Vtiger/uitypes/MultiImage.php is not working properly because max-width and max-height are not supported by YetiforcePDF.
public function getTextParserDisplayValue($value, Vtiger_Record_Model $recordModel, $params)
{
$value = \App\Json::decode($value);
if (!$value) {
return '';
}
$images = $style = '';
if ($params) {
[$width, $height, $style] = array_pad(explode('|', $params, 3), 3, '');
if ($width) {
$style .= "max-width:$width;";
}
if ($height) {
$style .= "max-height:$height;";
}
} else {
$width = 100 / \count($value);
$style .= "max-width:$width%;";
$images .= '<div style="width:100%">';
}
foreach ($value as $item) {
$base64 = base64_encode(file_get_contents($item['path']));
$images .= "<img src=\"data:image/jpeg;base64,$base64\" style=\"$style\"/>";
}
if (!$params) {
$images .= '</div>';
}
return $images;
}
As a quick fix, I override with a custom version in /custom/modules/Vtiger/uitypes/MultiImage.php
public function getTextParserDisplayValue($value, Vtiger_Record_Model $recordModel, $params)
{
$value = \App\Json::decode($value);
if (!$value) {
return '';
}
$images = $style = '';
if ($params) {
[$width, $height, $style] = array_pad(explode('|', $params, 3), 3, '');
if ($width) {
$style .= "width:$width;";
}
if ($height) {
$style .= "height:$height;";
}
} else {
$width = 100 / \count($value);
$style .= "width:$width%;";
$images .= '<div style="width:100%">';
}
foreach ($value as $item) {
$base64 = base64_encode(file_get_contents($item['path']));
$images .= "<img src=\"data:image/jpeg;base64,$base64\" style=\"$style\"/>";
}
if (!$params) {
$images .= '</div>';
}
return $images;
}