mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Resize avatar image if too large 🌆 (#1512)
* Resize avatar image if too large 🌆
* Update CHANGELOG.md
This commit is contained in:
parent
2cd786f85d
commit
f1665f5155
2 changed files with 17 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
**Merged pull requests:**
|
||||
|
||||
- Release 2.4.4 🦩 ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Resize avatar image if too large 🌆 [\#1512](https://github.com/torrentpier/torrentpier/pull/1512) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Increased PASSWORD_MAX_LENGTH [\#1510](https://github.com/torrentpier/torrentpier/pull/1510) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Some security improvements 🔑 [\#1503](https://github.com/torrentpier/torrentpier/pull/1503) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Some security enhancements (Part 2) [\#1505](https://github.com/torrentpier/torrentpier/pull/1505) ([belomaxorka](https://github.com/belomaxorka))
|
||||
|
|
|
@ -161,8 +161,22 @@ class Upload
|
|||
|
||||
// width & height
|
||||
if (($this->cfg['max_width'] && $width > $this->cfg['max_width']) || ($this->cfg['max_height'] && $height > $this->cfg['max_height'])) {
|
||||
$this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']);
|
||||
return false;
|
||||
for ($i = 0, $max_try = 3; $i <= $max_try; $i++) {
|
||||
try {
|
||||
$image = new \claviska\SimpleImage();
|
||||
$image
|
||||
->fromFile($this->file['tmp_name'])
|
||||
->autoOrient()
|
||||
->resize($this->cfg['max_width'], $this->cfg['max_height'])
|
||||
->toFile($this->file['tmp_name']);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
if ($i == $max_try) {
|
||||
$this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $lang['UPLOAD_ERROR_NOT_IMAGE'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue