Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Duhell's avatar
Level 1

Image doesn't show in the form and table using SpatieMedia Plugin

Hello everyone, I have a problem using the Spatie Media Library Plugin by Filament, my configuration are all set to default, I didn't change anything and just follow the documentation but the image does not show or preview when edit. It just keeps loading and displaying "Waiting for size". Now, I tried to display it on the Table but no luck, it just shows the image broken logo.

Error: Access to fetch at 'http://localhost:8000/storage/1/01J9GBXXAMCRGCX1757XSFW561.jpg' from origin 'http://127.0.0.1:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Done php artisan storage:link. Done implements HasMedia and use InteractsWithMedia in the model.

This is my code for the Form. SpatieMediaLibraryFileUpload::make('news-attachment') ->required() ->label("Upload Image") ->image() ->maxSize(1024) ->helperText('(max 1MB)') ->responsiveImages() ->collection('news-attachment'),

This is my code for the Table Column. SpatieMediaLibraryImageColumn::make('news-attachment') ->collection('news-attachment')

In my model public function registerMediaCollections(?Media $media = null): void { $this->addMediaConversion('preview') ->fit(Fit::Contain, 300, 300) ->nonQueued(); }

0 likes
1 reply
Duhell's avatar
Level 1

Hello again.

I already solved the problem and what I did is just changing the APP_URL in the .env file from "http://localhost" to "http://127.0.0.1:8000" but if there are other solutions, kindly let me know. Thank you.

1 like

Please or to participate in this conversation.