FileUpdload not displaying file preview

Firstly, yes.. I linked the storage folder to the public folder. I have a model Event that has a nullable string column image. I want to have a default image that is displayed on the frontend when image is uploaded. The default image is at public/img/event/default-event.png The uploaded files from Filament should go to storage/app/public/event/xxx.png (public/storage/event/xxx.png) Currently, I have defined an Accessor on the model:
protected function image(): Attribute
{
return Attribute::make(
get: fn (?string $value) => Storage::url($value) ?? self::DEFAULT_IMAGE,
);
}
protected function image(): Attribute
{
return Attribute::make(
get: fn (?string $value) => Storage::url($value) ?? self::DEFAULT_IMAGE,
);
}
That Storage::url($value) is causing trouble for Filament, as it doesn't show the file preview when used with the FileUpload form component. For reference, this is the component in use:
Forms\Components\FileUpload::make('image')
->directory('img/event')
->image()
->imageEditor()
->downloadable()
->imageEditorAspectRatios([
null,
'16:9',
])->optimize('jpg'),
Forms\Components\FileUpload::make('image')
->directory('img/event')
->image()
->imageEditor()
->downloadable()
->imageEditorAspectRatios([
null,
'16:9',
])->optimize('jpg'),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server