F
Filamentβ€’13mo ago
Jamie Cee

FIle Upload Image preview on edit action load

When I choose to edit a record, if it has an image already, this doesnt appear on the edit screen. If I was to upload a new image, I'd have that preview, but not when an image already exists against the record?
No description
17 Replies
toeknee
toekneeβ€’13mo ago
Uploading it just puts into the browser, so it will be how it's re-rendered. Please confirm the storage disk config, the field config and if the file is publically accessible too.
Jamie Cee
Jamie CeeOPβ€’13mo ago
I believe so, I can view it in the table view as an image column:
No description
Jamie Cee
Jamie CeeOPβ€’13mo ago
Its just on the edit page, a user should be able to see the record that already exists And the URL that I store in the DB... I can go to the browser with it and the image loads correctly
toeknee
toekneeβ€’13mo ago
Are you storing the URL as a full URL or a URL Path?
Jamie Cee
Jamie CeeOPβ€’13mo ago
the 'avatar' field itself is a full url. but as a hidden field I also store the path
Jamie Cee
Jamie CeeOPβ€’13mo ago
No description
Jamie Cee
Jamie CeeOPβ€’13mo ago
Like that
toeknee
toekneeβ€’13mo ago
That's why, never store as a full URL This is the reason we have disks etc in Laravel. Try removing the URL and storage off. so: /offers/01 etc
Jamie Cee
Jamie CeeOPβ€’13mo ago
The main reason for the full URL as it's what our FE request on the API side, and easier to just store it. Maybve swapping them around would work, Ill give that a go
toeknee
toekneeβ€’13mo ago
No you shouldn't do that, only the S3 driver does that. If you want the full URL on the API put a getter/setter into the model for avatar_url which returns it with storage url. When you go live now, you have to upload the urls.
Jamie Cee
Jamie CeeOPβ€’13mo ago
So that would look the same in the API but we dont store it as a full URL? Just trying to learn πŸ™‚
toeknee
toekneeβ€’13mo ago
Yep
Jamie Cee
Jamie CeeOPβ€’13mo ago
Cool. Thank you πŸ™‚
toeknee
toekneeβ€’13mo ago
ChatGPT Should show you how to quickly do it, then ask it to explain it so you get a better understanding, it's just a basic Laravel Model option
Jamie Cee
Jamie CeeOPβ€’13mo ago
Is this for the getter/setter?
toeknee
toekneeβ€’13mo ago
Yeah
Jamie Cee
Jamie CeeOPβ€’13mo ago
Perfect, cheers All sorted and running now. Cheers for the help πŸ™‚
Want results from more Discord servers?
Add your server