© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Rus

How to control order of images in spatie media library field while saving?

I have a SpatieMediaLibraryFileUpload field for images in my Filament resource. It's multiple. When I choose or drag&drop files there they have some order in preview. But after I save them their order is changed. But it's a bit confusing thing - before you save them, you can't be sure what order you'll get. What we could do to be sure that order in the preview will be saved? Thanks!

My field looks like that now:

'images' => SpatieMediaLibraryFileUpload::make('images')
                ->label(__('general.images.label'))
                ->collection('images')
                ->columnSpan(2)
                ->imagePreviewHeight('250')
                ->panelLayout('grid')
                ->image()
                ->multiple()
                ->enableOpen()
                ->enableReordering()
                ->uploadProgressIndicatorPosition('left')
                ->disk(app()->environment('local') ? 'public' : config('media-library.disk_name'))
                ->visibility(function () {
                    return (config('media-library.disk_name') === 's3') && config('someproject.store_images_private', true) ? 'private' : 'public';
                })
                ->reactive(),
'images' => SpatieMediaLibraryFileUpload::make('images')
                ->label(__('general.images.label'))
                ->collection('images')
                ->columnSpan(2)
                ->imagePreviewHeight('250')
                ->panelLayout('grid')
                ->image()
                ->multiple()
                ->enableOpen()
                ->enableReordering()
                ->uploadProgressIndicatorPosition('left')
                ->disk(app()->environment('local') ? 'public' : config('media-library.disk_name'))
                ->visibility(function () {
                    return (config('media-library.disk_name') === 's3') && config('someproject.store_images_private', true) ? 'private' : 'public';
                })
                ->reactive(),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Spatie media library responsive images
FilamentFFilament / ❓┊help
2y ago
Replicate images - Spatie Media Library Image
FilamentFFilament / ❓┊help
3y ago
How to order images when using Media Library
FilamentFFilament / ❓┊help
15mo ago
Spatie media library not Saving on S3
FilamentFFilament / ❓┊help
3y ago