N°3670 Add a parameter to chose max file size to be displayed as a preview icon

This commit is contained in:
Stephen Abello
2021-02-15 15:44:23 +01:00
parent a53485d08f
commit e8f26bdf18
2 changed files with 4 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ SetupWebPage::AddModule(
'allowed_classes' => array('Ticket'), // List of classes for which to manage "Attachments"
'position' => 'relations', // Where to display the attachments: relations | properties
'preview_max_width' => 290,
'icon_preview_max_size' => 500000, // Maximum size for attachment preview to be displayed as an icon. In bits
),
)
);

View File

@@ -506,12 +506,14 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer
$sAttachmentThumbUrl = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($sFileName);
$sIconClass = '';
$iMaxWidth = MetaModel::GetModuleSetting('itop-attachments', 'preview_max_width', 290);
$iMaxSizeForPreview = MetaModel::GetModuleSetting('itop-attachments', 'icon_preview_max_size', self::MAX_SIZE_FOR_PREVIEW);
$sPreviewNotAvailable = Dict::S('Attachments:PreviewNotAvailable');
$sPreviewMarkup = $sPreviewNotAvailable;
if ($oDoc->IsPreviewAvailable())
{
$sIconClass = ' preview';
if ($oDoc->GetSize() <= self::MAX_SIZE_FOR_PREVIEW)
if ($oDoc->GetSize() <= $iMaxSizeForPreview)
{
$sAttachmentThumbUrl = $sDocDownloadUrl;
}