[ticket/15769] Minor clean up of avatar cropping

PHPBB3-15769
This commit is contained in:
mrgoldy 2020-05-10 00:39:54 +02:00 committed by Marc Alexander
parent 4d860bf967
commit 0bff9e605b
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 4 additions and 7 deletions

View file

@ -24,7 +24,7 @@ use phpbb\storage\exception\exception as storage_exception;
use phpbb\storage\storage; use phpbb\storage\storage;
/** /**
* Handles avatars uploaded to the board * Handles avatars uploaded to the board.
*/ */
class upload extends \phpbb\avatar\driver\driver class upload extends \phpbb\avatar\driver\driver
{ {
@ -241,7 +241,6 @@ class upload extends \phpbb\avatar\driver\driver
*/ */
public function delete($row) public function delete($row)
{ {
$error = array(); $error = array();
$prefix = $this->config['avatar_salt'] . '_'; $prefix = $this->config['avatar_salt'] . '_';
$ext = substr(strrchr($row['avatar'], '.'), 1); $ext = substr(strrchr($row['avatar'], '.'), 1);

View file

@ -213,7 +213,7 @@ class image_cropper
$flip_mode |= $flip_horizontally ? IMG_FLIP_HORIZONTAL : 0; $flip_mode |= $flip_horizontally ? IMG_FLIP_HORIZONTAL : 0;
$flip_mode |= $flip_vertically ? IMG_FLIP_VERTICAL : 0; $flip_mode |= $flip_vertically ? IMG_FLIP_VERTICAL : 0;
if ($flip_mode !== 0) if (0 !== $flip_mode)
{ {
imageflip($image, $flip_mode); imageflip($image, $flip_mode);
} }
@ -249,13 +249,11 @@ class image_cropper
*/ */
public static function crop_image($image, int $x, int $y, int $width, int $height) public static function crop_image($image, int $x, int $y, int $width, int $height)
{ {
$new_image = imagecrop($image, [ return false !== ($new_image = imagecrop($image, [
'x' => $x, 'x' => $x,
'y' => $y, 'y' => $y,
'width' => $width, 'width' => $width,
'height' => $height, 'height' => $height,
]); ])) ? $new_image : $image;
return false !== $new_image ? $new_image : $image;
} }
} }