浏览代码

Merge pull request #1455 from zhaiyuxin103/2.0

🎈 perf(thumbnail): 访问缩略图时不检查图片是否存在
Jiang Qinghua 4 年之前
父节点
当前提交
315924d5d0
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. 4 5
      src/Traits/Resizable.php

+ 4 - 5
src/Traits/Resizable.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Traits;
 
-use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Str;
 
 trait Resizable
@@ -18,7 +17,7 @@ trait Resizable
     public function thumbnail($type, $attribute = 'image', $disk = null)
     {
         // Return empty string if the field not found
-        if (! isset($this->attributes[$attribute])) {
+        if (!isset($this->attributes[$attribute])) {
             return '';
         }
 
@@ -27,7 +26,7 @@ trait Resizable
 
         $thumbnail = $this->getThumbnailPath($image, $type);
 
-        return Storage::disk($disk ?: config('admin.upload.disk'))->exists($thumbnail) ? $thumbnail : null;
+        return $thumbnail;
     }
 
     /**
@@ -44,9 +43,9 @@ trait Resizable
         $ext = pathinfo($image, PATHINFO_EXTENSION);
 
         // We remove extension from file name so we can append thumbnail type
-        $name = Str::replaceLast('.'.$ext, '', $image);
+        $name = Str::replaceLast('.' . $ext, '', $image);
 
         // We merge original name + type + extension
-        return $name.'-'.$type.'.'.$ext;
+        return $name . '-' . $type . '.' . $ext;
     }
 }