mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
avoid 404 error when loading image in autocomplete
This commit is contained in:
@@ -2656,7 +2656,7 @@ class utils
|
||||
$sMentionItemUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class='.$sMentionClass.'&id={id}';
|
||||
|
||||
$sMentionItemPictureTemplate = (empty(MetaModel::GetImageAttributeCode($sMentionClass))) ? '' : <<<HTML
|
||||
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="background-image: url('{picture_url}');">{initials}</span>
|
||||
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="{picture_style}">{initials}</span>
|
||||
HTML;
|
||||
$sMentionItemTemplate = <<<HTML
|
||||
<li class="ibo-vendors-ckeditor--autocomplete-item" data-id="{id}">{$sMentionItemPictureTemplate}<span class="ibo-vendors-ckeditor--autocomplete-item-title">{friendlyname}</span></li>
|
||||
|
||||
@@ -2720,10 +2720,9 @@ EOF
|
||||
$sObjectClass = get_class($oObject);
|
||||
$iObjectId = $oObject->GetKey();
|
||||
$aMatch = [
|
||||
'class' => $sObjectClass,
|
||||
'id' => $iObjectId,
|
||||
'class' => $sObjectClass,
|
||||
'id' => $iObjectId,
|
||||
'friendlyname' => $oObject->Get('friendlyname'),
|
||||
'initials' => '',
|
||||
];
|
||||
|
||||
// Try to retrieve image for contact
|
||||
@@ -2731,13 +2730,15 @@ EOF
|
||||
/** @var \ormDocument $oImage */
|
||||
$oImage = $oObject->Get($sObjectImageAttCode);
|
||||
if (!$oImage->IsEmpty()) {
|
||||
$aMatch['picture_url'] = $oImage->GetDisplayURL($sObjectClass, $iObjectId, $sObjectImageAttCode);
|
||||
$aMatch['picture_style'] = "background-image: url('".$oImage->GetDisplayURL($sObjectClass, $iObjectId, $sObjectImageAttCode)."')";
|
||||
$aMatch['initials'] = '';
|
||||
} else {
|
||||
// If no image found, fallback on initials
|
||||
$aMatch['picture_style'] = '';
|
||||
$aMatch['initials'] = utils::ToAcronym($oObject->Get('friendlyname'));
|
||||
}
|
||||
}
|
||||
|
||||
// If no image found, fallback on initials
|
||||
$aMatch['initials'] = array_key_exists('picture_url', $aMatch) ? '' : utils::ToAcronym($oObject->Get('friendlyname'));
|
||||
|
||||
$aMatches[] = $aMatch;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user