From 5d51568c4e2814aa1fd3168d59d2b2261b504918 Mon Sep 17 00:00:00 2001 From: mrded Date: Thu, 28 Aug 2014 17:26:19 +0100 Subject: [PATCH] File validate image resolution inaccurate in some situations --- includes/file.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/file.inc b/includes/file.inc index d3008cc..f0ea7dd 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1816,6 +1816,14 @@ function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0, // Check first that the file is an image. if ($info = image_get_info($file->uri)) { + if ($maximum_dimensions && ($maximum_dimensions == $minimum_dimensions)) { + // Check that dimensions is exactly that given. + list($width, $height) = explode('x', $maximum_dimensions); + if ($info['width'] != $width || $info['height'] != $height) { + return array(t('The image must be exactly %dimensions pixels.', array('%dimensions' => $maximum_dimensions))); + } + } + if ($maximum_dimensions) { // Check that it is smaller than the given dimensions. list($width, $height) = explode('x', $maximum_dimensions); -- 1.8.5.2 (Apple Git-48)