From e8f26bdf18b85d48ed02eae61b4d939506b42a57 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Mon, 15 Feb 2021 15:44:23 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03670=20Add=20a=20parameter=20to=20chose?= =?UTF-8?q?=20max=20file=20size=20to=20be=20displayed=20as=20a=20preview?= =?UTF-8?q?=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datamodels/2.x/itop-attachments/module.itop-attachments.php | 1 + .../2.x/itop-attachments/renderers.itop-attachments.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/datamodels/2.x/itop-attachments/module.itop-attachments.php b/datamodels/2.x/itop-attachments/module.itop-attachments.php index 3d3448b33..d7a446482 100644 --- a/datamodels/2.x/itop-attachments/module.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/module.itop-attachments.php @@ -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 ), ) ); diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php index 1c0d74c1d..679fd63e2 100644 --- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php @@ -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; }