瀏覽代碼

Add support .webp for avatar

Visman 4 年之前
父節點
當前提交
469436ad1b
共有 3 個文件被更改,包括 4 次插入2 次删除
  1. 0 1
      app/Core/Files.php
  2. 3 0
      app/Core/Image.php
  3. 1 1
      app/Models/Pages/Profile/Edit.php

+ 0 - 1
app/Core/Files.php

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

+ 3 - 0
app/Core/Image.php

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

+ 1 - 1
app/Models/Pages/Profile/Edit.php

@@ -120,7 +120,7 @@ class Edit extends Profile
 
 
                 if ($v->upload_avatar instanceof Image) {
                 if ($v->upload_avatar instanceof Image) {
                     $name   = $this->c->Secury->randomPass(8);
                     $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
                     $result = $v->upload_avatar
                         ->rename(true)
                         ->rename(true)
                         ->rewrite(false)
                         ->rewrite(false)