Mentions: Show initials when no picture for contact

This commit is contained in:
Molkobain
2021-04-05 21:20:21 +02:00
parent 8b25679df8
commit 5fa2caac29
4 changed files with 24 additions and 15 deletions

View File

@@ -2723,14 +2723,21 @@ EOF
'class' => $sObjectClass,
'id' => $iObjectId,
'friendlyname' => $oObject->Get('friendlyname'),
'initials' => '',
];
if(!empty($sObjectImageAttCode)) {
// Try to retrieve image for contact
if (!empty($sObjectImageAttCode)) {
/** @var \ormDocument $oImage */
$oImage = $oObject->Get($sObjectImageAttCode);
$aMatch['picture_url'] = $oImage->GetDisplayURL($sTargetClass, $iObjectId, $sObjectImageAttCode);
if (!$oImage->IsEmpty()) {
$aMatch['picture_url'] = $oImage->GetDisplayURL($sTargetClass, $iObjectId, $sObjectImageAttCode);
}
}
// If no image found, fallback on initials
$aMatch['initials'] = array_key_exists('picture_url', $aMatch) ? '' : utils::ToAcronym($oObject->Get('friendlyname'));
$aMatches[] = $aMatch;
}
}