From a88365ca4927cf3fff1217d4f8990f1a799b5f14 Mon Sep 17 00:00:00 2001 From: Guillaume Lajarige Date: Fri, 30 Sep 2016 11:24:30 +0000 Subject: [PATCH] Resize on AttributeImage crashes when gd extension is not installed. Implemented a fallback so images are stored as is (original size) when gd extension is not available. A warning message is displayed during the setup. SVN:trunk[4429] --- application/utils.inc.php | 11 +++++++++++ setup/setuputils.class.inc.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 45d6ee441..eddb7a46e 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1279,10 +1279,21 @@ class utils */ public static function ResizeImageToFit(ormDocument $oImage, $iWidth, $iHeight, $iMaxImageWidth, $iMaxImageHeight) { + // If image size smaller than maximums, we do nothing if (($iWidth <= $iMaxImageWidth) && ($iHeight <= $iMaxImageHeight)) { return $oImage; } + + + // If gd extension is not loaded, we put a warning in the log and return the image as is + if (extension_loaded('gd') === false) + { + IssueLog::Warning('Image could not be resized as the "gd" extension does not seem to be loaded. It will remain as ' . $iWidth . 'x' . $iHeight . ' instead of ' . $iMaxImageWidth . 'x' . $iMaxImageHeight); + return $oImage; + } + + switch($oImage->GetMimeType()) { case 'image/gif': diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index f6c83019e..c7f5c43a3 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -88,7 +88,7 @@ class SetupUtils $aMandatoryExtensions = array('mysqli', 'iconv', 'simplexml', 'soap', 'hash', 'json', 'session', 'pcre', 'dom', 'zip'); $aOptionalExtensions = array('mcrypt' => 'Strong encryption will not be used.', 'ldap' => 'LDAP authentication will be disabled.', - 'gd' => 'PDF export will be disabled'); + 'gd' => 'PDF export will be disabled. Also, image resizing will be disabled on profile pictures (May increase database size).'); asort($aMandatoryExtensions); // Sort the list to look clean ! ksort($aOptionalExtensions); // Sort the list to look clean ! $aExtensionsOk = array();