ensure there is a thumbnail variant before returning url

This commit is contained in:
2024-04-28 17:32:01 +10:00
parent bb440497eb
commit d1b94f9183

View File

@@ -138,9 +138,11 @@ class Media extends Model
*/ */
public function getThumbnailAttribute(): string public function getThumbnailAttribute(): string
{ {
$url = $this->url('thumbnail', true); if($this->hasVariant('thumbnail')) {
if($url !== '') { $url = $this->url('thumbnail', true);
return $url; if($url !== '') {
return $url;
}
} }
$thumbnail = '/thumbnails/' . pathinfo($this->name, PATHINFO_EXTENSION) . '.webp'; $thumbnail = '/thumbnails/' . pathinfo($this->name, PATHINFO_EXTENSION) . '.webp';