Skip to content

Commit

Permalink
fix media trait front image attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
guysolamour committed Jan 13, 2022
1 parent a85f910 commit 727de93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Traits/MediaableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ trait MediaableTrait

public function getFrontImageAttribute()
{
return $this->getMedia(config('administrable.media.collections.front.label', 'default'), ['select' => true])->first();
$media = $this->getMedia(config('administrable.media.collections.front.label', 'default'), ['select' => true])->first();

if (!$media && !empty($this->images)){
return Arr::first($this->images);
}

return $media;
}

public function getFrontImageUrl(string $conversionName = ''): ?string
Expand Down

0 comments on commit 727de93

Please sign in to comment.