From c4c5a6907da37d3e10dbd72a9b919ea04cc1a1ff Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:31:56 -0600 Subject: [PATCH] Update Status model --- app/Status.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Status.php b/app/Status.php index abb1c4bb..d0f734ca 100644 --- a/app/Status.php +++ b/app/Status.php @@ -32,9 +32,18 @@ class Status extends Model return $this->hasMany(Media::class)->orderBy('order', 'asc')->first(); } - public function thumb() + public function viewType() { - if($this->media->count() == 0 || $this->is_nsfw) { + $media = $this->firstMedia(); + $type = explode('/', $media->mime); + return $type[0]; + } + + public function thumb($showNsfw = false) + { + $type = $this->viewType(); + $is_nsfw = !$showNsfw ? $this->is_nsfw : false; + if($this->media->count() == 0 || $is_nsfw || $type != 'image') { return "data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; } return url(Storage::url($this->firstMedia()->thumbnail_path));