mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update Media model
This commit is contained in:
parent
ff2c16fe74
commit
7a431af93a
1 changed files with 6 additions and 3 deletions
|
@ -20,8 +20,8 @@ class Media extends Model
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'srcset' => 'array',
|
'srcset' => 'array',
|
||||||
'deleted_at' => 'datetime'
|
'deleted_at' => 'datetime'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function status()
|
public function status()
|
||||||
|
@ -63,7 +63,7 @@ class Media extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) {
|
if($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) {
|
||||||
return $this->remote_media || Str::startsWith($this->media_path, 'http') ?
|
return $this->remote_media || Str::startsWith($this->media_path, 'http') ?
|
||||||
$this->media_path :
|
$this->media_path :
|
||||||
url(Storage::url($this->media_path));
|
url(Storage::url($this->media_path));
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,9 @@ class Media extends Model
|
||||||
|
|
||||||
public function mimeType()
|
public function mimeType()
|
||||||
{
|
{
|
||||||
|
if(!$this->mime) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return explode('/', $this->mime)[0];
|
return explode('/', $this->mime)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue