Update Media model, add cdn support to url and thumbnailUrl methods

pull/2587/head
Daniel Supernault 5 years ago
parent a98b65bf5c
commit 57fa889d16
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7

@ -29,25 +29,38 @@ class Media extends Model
public function url()
{
if($this->mime === 'video/mp4') {
return url(Storage::url($this->thumbnail_path ?? 'public/no-preview.png'));
}
if($this->cdn_url) {
return $this->cdn_url;
}
if(!empty($this->remote_media) && $this->remote_url) {
//$url = \App\Services\MediaProxyService::get($this->remote_url, $this->mime);
$url = $this->remote_url;
} else {
$path = $this->media_path;
$url = $this->cdn_url ?? config('app.url') . Storage::url($path);
return $this->remote_url;
}
return $url;
return url(Storage::url($this->media_path));
}
public function thumbnailUrl()
{
if($this->remote_media == true) {
return $this->remote_url;
} else {
$path = $this->thumbnail_path ?? 'public/no-preview.png';
return url(Storage::url($path));
if($this->mime === 'video/mp4') {
return url(Storage::url($this->thumbnail_path ?? 'public/no-preview.png'));
}
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()

Loading…
Cancel
Save