Skip to content

Commit

Permalink
Merge pull request #4323 from ExpressionEngine/bug/7.x/handle-getimag…
Browse files Browse the repository at this point in the history
…esize-errors

Resolved #4319 by showing an error when image properties can't be gathered
  • Loading branch information
bryannielsen committed May 21, 2024
2 parents c4b2dda + 153a95c commit faae17d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions system/ee/language/english/image_lib_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

'imglib_save_failed' => 'Unable to save the image. Please make sure the image and file directory are writable.',

'imglib_properties_failed' => 'Unable to gather properties of the image. Please make sure the image is valid and readable.',

'imglib_source_image_required' => 'You must specify a source image in your preferences.',

'imglib_unsupported_imagecreate' => 'Your server does not support the GD function required to process this type of image.',
Expand Down
6 changes: 6 additions & 0 deletions system/ee/legacy/libraries/Image_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,12 @@ public function get_image_properties($path = '', $return = false)

$vals = @getimagesize($path);

if (! $vals) {
$this->set_error('imglib_properties_failed');

return false;
}

$types = array(IMAGETYPE_GIF => 'gif', IMAGETYPE_JPEG => 'jpeg', IMAGETYPE_PNG => 'png', '18' => 'webp');

$mime = (isset($types[$vals['2']])) ? 'image/' . $types[$vals['2']] : 'image/jpg';
Expand Down

0 comments on commit faae17d

Please sign in to comment.