From 71e9c50a5735ed3fe3d918c900a919bb103d01af Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 16 Sep 2022 09:08:43 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1618 prevent exif_read_data call on non-jpg images in Pageimage.php --- wire/core/Pageimage.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wire/core/Pageimage.php b/wire/core/Pageimage.php index 5c0ca119..882c8cf6 100644 --- a/wire/core/Pageimage.php +++ b/wire/core/Pageimage.php @@ -489,12 +489,13 @@ class Pageimage extends Pagefile { $imageInfo = $this->imageInfo; $filename = is_string($reset) && file_exists($reset) ? $reset : ''; + $ext = $this->ext; if(!$reset && $imageInfo['width'] && !$filename) { return $imageInfo; } - if($this->ext == 'svg') { + if($ext == 'svg') { $imageInfo = array_merge($imageInfo, $this->getImageInfoSVG($filename)); } else { if($filename) { @@ -509,7 +510,7 @@ class Pageimage extends Pagefile { } else if($info) { $imageInfo['width'] = $info[0]; $imageInfo['height'] = $info[1]; - if(function_exists('exif_read_data')) { + if(function_exists('exif_read_data') && ($ext === 'jpg' || $ext === 'jpeg')) { $exif = $filename ? @exif_read_data($filename) : @exif_read_data($this->filename); if(!empty($exif['Orientation']) && (int) $exif['Orientation'] > 4) { // Image has portrait orientation so reverse width and height info