From ce01dad8756fe7545d291c3c0b32a15b50613288 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Wed, 8 Dec 2021 12:51:36 +0100 Subject: [PATCH] utils::GetImageSize can be simplified since minimal PHP version is 7.1.3 --- application/utils.inc.php | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index de9425d576..074866d3ec 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1944,28 +1944,18 @@ class utils return $sCss; } - + + /** + * Get the size of an image from a string. + * + * @see \getimagesizefromstring() + * @param $sImageData string The image data, as a string. + * + * @return array|false + */ public static function GetImageSize($sImageData) { - if (function_exists('getimagesizefromstring')) // PHP 5.4.0 or higher - { - $aRet = @getimagesizefromstring($sImageData); - } - else if(ini_get('allow_url_fopen')) - { - // work around to avoid creating a tmp file - $sUri = 'data://application/octet-stream;base64,'.base64_encode($sImageData); - $aRet = @getimagesize($sUri); - } - else - { - // Damned, need to create a tmp file - $sTempFile = tempnam(SetupUtils::GetTmpDir(), 'img-'); - @file_put_contents($sTempFile, $sImageData); - $aRet = @getimagesize($sTempFile); - @unlink($sTempFile); - } - return $aRet; + return @getimagesizefromstring($sImageData); } /**