Spatie Media Library records media but does not display it.
I am using the Spatie Media Library package (https://filamentphp.com/plugins/filament-spatie-media-library).
In the form I created the upload:
After saving the form, the media record is created in the Media table correctly, but the media disappears from my form as if it were empty. I also have the media column in my table (which I previously used with common upload), but nothing is saved in it. I believe it is not necessary.
However, on my blade page I am trying to display the image but the return is empty:
What am I doing wrong?
17 Replies
what's your storage driver (local, S3, etc)?
if local maybe you forgot to run
php artisan storage:link
local and the link already exists. everything works fine with the regular upload form and the image is displayed correctly. However, with Spatie Media Library it simply doesn't work.
Whats the browser console say?
Nothing, it's empty. I tried in 3 different browsers and the console doesn't have any errors
I also tried another storage driver and the image is saved on the server and the record created in the database. However, it is not displayed in the form after saving nor when I need to display it.
Is this a custom livewire component?
no. Edit Resource Page
Hm........ Not making much sense .. Please ensure you are updated using the latest version, with filament upgrade run and with npm run dev.
filament/filament 3.2.58
filament/spatie-laravel-media-library-plugin 3.2
So upgrade filament.... you are 40 versions behind
media library plugin might be out of date too.
I'll check. thanks
I updated all the packages and I'm still having the same problem. I even removed the vendor and node_modules folder and reinstalled everything, cleared cache, etc.
Ok… can you create a reproduction repository? So we can review?
I created a new laravel installation and tested it and everything worked fine. Thank you for your help.
have you checked the
.env
APP_URL
? make sure you don't have a slash at the end - the correct format is APP_URL=myproject.localhost
check the asset url too
I tried with http://localhost and http://localhost:8000 and in the published project I tried using the site's https url and the problem is the same.
Where can I find the asset url?
The interesting thing is that if I start a new project and install only filament and spatie-laravel-media-library-plugin everything works fine. But then I finished installing the packages I need and created the resources I need and then it stopped working again. It seems to be incompatibility with some package or something.
ASSET_URL=
in the .env
So it sounds like you are fighting with a URL issue,
Have you set the APP_URL is set correctly in the? Maybe also try using Herd for your Stack
how you serve your app in your local environment? i recommend using laravel herd
remember to remove the slash at the end of the url