F
Filament8mo ago
Mocus

ImageColumn not displaying .png

so i have a table and trying to use a image:
ImageColumn::make('image_attribute')
->url(asset('Types/10039_32.png'))
->circular(),
ImageColumn::make('image_attribute')
->url(asset('Types/10039_32.png'))
->circular(),
i have my Types folder with images in public folder but it's not loading them
4 Replies
Mocus
MocusOP8mo ago
update: i've inspected the element in chrome and can see the HTML code there, with a resource link which when i click on takes me to the image and loads fine.
toeknee
toeknee8mo ago
->url() is where the image column links too. you want
->default(asset('Types/10039_32.png'))
->default(asset('Types/10039_32.png'))
Mocus
MocusOP8mo ago
yeah i just figured out the default is what i need -.- silly me! im no pro, but can i access the $record attribute in this field to something like {typeID} for anyone else looking to do the same, looks like the way to do this:
ImageColumn::make('avatar')
->default(fn ($record) => asset("Types/{$record->types->typeID}_64.png"))
ImageColumn::make('avatar')
->default(fn ($record) => asset("Types/{$record->types->typeID}_64.png"))
toeknee
toeknee8mo ago
That should work for the column, usually you would use: ->getStateUsing(fn() => ) opposed to default
Want results from more Discord servers?
Add your server