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,10 +138,12 @@ class Media extends Model
*/
public function getThumbnailAttribute(): string
{
if($this->hasVariant('thumbnail')) {
$url = $this->url('thumbnail', true);
if($url !== '') {
return $url;
}
}
$thumbnail = '/thumbnails/' . pathinfo($this->name, PATHINFO_EXTENSION) . '.webp';