Add support .webp for avatar

This commit is contained in:
Visman 2020-10-04 13:46:14 +07:00
parent 29d9db3727
commit 469436ad1b
3 changed files with 4 additions and 2 deletions

View file

@ -941,7 +941,6 @@ class Files
if (\is_array($file['tmp_name'])) {
$result = [];
foreach ($file['tmp_name'] as $key => $value) {
// изображение не было отправлено
if (
'' === $file['name'][$key]
&& empty($file['size'][$key])

View file

@ -132,6 +132,9 @@ class Image extends File
case 'gif':
$result = @\imagegif($this->image, $path);
break;
case 'webp':
$result = @\imagewebp($this->image, $path, $this->quality);
break;
default:
$this->error = 'File type not supported';

View file

@ -120,7 +120,7 @@ class Edit extends Profile
if ($v->upload_avatar instanceof Image) {
$name = $this->c->Secury->randomPass(8);
$path = $this->c->DIR_PUBLIC . "{$this->c->config->o_avatars_dir}/{$name}.(jpg|png|gif)";
$path = $this->c->DIR_PUBLIC . "{$this->c->config->o_avatars_dir}/{$name}.(jpg|png|gif|webp)";
$result = $v->upload_avatar
->rename(true)
->rewrite(false)