diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index e2004cd82..6e22a32e6 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -7278,31 +7278,62 @@ class AttributeImage extends AttributeBlob
return true;
}
+ /**
+ * @param \ormDocument $value
+ * @param \DBObject $oHostObject
+ * @param bool $bLocalize
+ *
+ * @return string
+ */
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
{
+ $sRet = '';
+
$iMaxWidthPx = $this->Get('display_max_width').'px';
$iMaxHeightPx = $this->Get('display_max_height').'px';
- $sUrl = $this->Get('default_image');
- $sRet = ($sUrl !== null) ? '' : '';
- if (is_object($value) && !$value->IsEmpty())
- {
- if ($oHostObject->IsNew() || ($oHostObject->IsModified() && (array_key_exists($this->GetCode(),
- $oHostObject->ListChanges()))))
- {
- // If the object is modified (or not yet stored in the database) we must serve the content of the image directly inline
- // otherwise (if we just give an URL) the browser will be given the wrong content... and may cache it
- $sUrl = 'data:'.$value->GetMimeType().';base64,'.base64_encode($value->GetData());
- }
- else
- {
- $sUrl = $value->GetDownloadURL(get_class($oHostObject), $oHostObject->GetKey(), $this->GetCode());
- }
- $sRet = '
';
+
+ $sDefaultImageUrl = $this->Get('default_image');
+ if ($sDefaultImageUrl !== null) {
+ $sRet = $this->GetHtmlForImageUrl($sDefaultImageUrl, $iMaxWidthPx, $iMaxHeightPx);
+ }
+
+ $sCustomImageUrl = $this->GetAttributeImageFileUrl($value, $oHostObject);
+ if ($sCustomImageUrl !== null) {
+ $sRet = $this->GetHtmlForImageUrl($sCustomImageUrl, $iMaxWidthPx, $iMaxHeightPx);
}
return '