© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
pepe.nectar

SpatieMediaLibraryImageEntry

I'm trying to use the SpatieMediaLibraryImageEntry with a model that has a belongsTo relationship and seems not to work.

If I use te SpatieMediaLibraryImageEntry in an infolist of a model that implemens HasMedia, it works. It looks for a 'media' relationship and query it for getting the first image associated with the record.

However, and here comes my problem, if I try to use SpatieMediaLibraryImageEntry in a model that have a belongsTo relationship with the model that has the media, it doesn't works.

Suppose that I have the model Post which implements the HasMedia interface. And other model Comment, so posts can have many comments, and a comment belongs to a post.

If I'm not using spatie media library, and post have a column called image, in a post resource/infolist, I can use an ImageEntry::make('image'), and in the case of using spatie media library, it will be SpatieMediaLibraryImageEntry::make('whatever') and the first image will be rendered.

But in a comments infolist where I try to show only one comment and show the post image, without spatie ImageEntry::make('post.image') works, but when using spatie image library SpatieMediaLibraryImageEntry::('post') doesn't works. It looks like that it doens't tries to resolve the post relationship to use it as the record and look for the 'media' relationship in the post record.

I'm start to think that is something that SpatieMediaLibraryImageEntry is not designed to work with. Any idea?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SpatieMediaLibraryImageEntry stopped displaying images
FilamentFFilament / ❓┊help
2y ago
SpatieMediaLibraryImageEntry error when using parent component relationship from Infolist
FilamentFFilament / ❓┊help
3y ago
SpatieMediaLibraryImageEntry error Attempt to read property "media" on null on RepeaterEntry
FilamentFFilament / ❓┊help
3y ago
Filling a SpatieMediaLibraryImageEntry field programmatically on a new Model (not saved yet)
FilamentFFilament / ❓┊help
3y ago