mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update Media model, add cdn support to url and thumbnailUrl methods
This commit is contained in:
parent
a98b65bf5c
commit
57fa889d16
1 changed files with 25 additions and 12 deletions
|
@ -29,25 +29,38 @@ class Media extends Model
|
||||||
|
|
||||||
public function url()
|
public function url()
|
||||||
{
|
{
|
||||||
if(!empty($this->remote_media) && $this->remote_url) {
|
if($this->mime === 'video/mp4') {
|
||||||
//$url = \App\Services\MediaProxyService::get($this->remote_url, $this->mime);
|
return url(Storage::url($this->thumbnail_path ?? 'public/no-preview.png'));
|
||||||
$url = $this->remote_url;
|
|
||||||
} else {
|
|
||||||
$path = $this->media_path;
|
|
||||||
$url = $this->cdn_url ?? config('app.url') . Storage::url($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
if($this->cdn_url) {
|
||||||
|
return $this->cdn_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($this->remote_media) && $this->remote_url) {
|
||||||
|
return $this->remote_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url(Storage::url($this->media_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function thumbnailUrl()
|
public function thumbnailUrl()
|
||||||
{
|
{
|
||||||
if($this->remote_media == true) {
|
if($this->mime === 'video/mp4') {
|
||||||
return $this->remote_url;
|
return url(Storage::url($this->thumbnail_path ?? 'public/no-preview.png'));
|
||||||
} else {
|
|
||||||
$path = $this->thumbnail_path ?? 'public/no-preview.png';
|
|
||||||
return url(Storage::url($path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->thumbnail_url) {
|
||||||
|
return $this->thumbnail_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->remote_url || $this->thumbnail_path) {
|
||||||
|
return url(Storage::url(
|
||||||
|
$this->remote_url ??
|
||||||
|
$this->thumbnail_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
return url(Storage::url('public/no-preview.png'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function thumb()
|
public function thumb()
|
||||||
|
|
Loading…
Reference in a new issue