Explorar o código

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.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4429 a333f486-631f-4898-b8df-5754b55c2be0
glajarige %!s(int64=8) %!d(string=hai) anos
pai
achega
3bc3cdafc1
Modificáronse 2 ficheiros con 12 adicións e 1 borrados
  1. 11 0
      application/utils.inc.php
  2. 1 1
      setup/setuputils.class.inc.php

+ 11 - 0
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':

+ 1 - 1
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();