Просмотр исходного кода

Add missing thumbnail fallback

Daniel Supernault 6 лет назад
Родитель
Сommit
03a4bb8d80
4 измененных файлов с 4 добавлено и 5 удалено
  1. 2 4
      app/Media.php
  2. 1 1
      app/Status.php
  3. 1 0
      storage/app/public/.gitignore
  4. BIN
      storage/app/public/no-preview.png

+ 2 - 4
app/Media.php

@@ -41,10 +41,8 @@ class Media extends Model
 
     public function thumbnailUrl()
     {
-        $path = $this->thumbnail_path;
-        $url = Storage::url($path);
-
-        return url($url);
+        $path = $this->thumbnail_path ?? 'public/no-preview.png';
+        return url(Storage::url($path));
     }
 
     public function thumb()

+ 1 - 1
app/Status.php

@@ -80,7 +80,7 @@ class Status extends Model
             $type = $this->type ?? $this->setType();
             $is_nsfw = !$showNsfw ? $this->is_nsfw : false;
             if ($this->media->count() == 0 || $is_nsfw || !in_array($type,['photo', 'photo:album'])) {
-                return 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
+                return url(Storage::url('public/no-preview.png'));
             }
 
             return url(Storage::url($this->firstMedia()->thumbnail_path));

+ 1 - 0
storage/app/public/.gitignore

@@ -1,2 +1,3 @@
 *
 !.gitignore
+!no-preview.png

BIN
storage/app/public/no-preview.png