To customize the display of the SpatieMediaLibraryFileUpload field in Filament, you can indeed use CSS to style the elements as you wish. You can also override the default views if you need more control over the HTML structure.
Here's how you can approach each method:
1. Custom CSS:
You can add custom CSS to your Filament admin panel by publishing the Filament config file and adding your custom stylesheets.
First, publish the Filament config file if you haven't already:
php artisan vendor:publish --tag=filament-config
Then, add your custom CSS file path to the stylesheets array in the config/filament.php file:
'stylesheets' => [
// Your existing stylesheets...
'/css/custom-filament.css', // Path to your custom CSS file
],
In your public/css/custom-filament.css file, you can add styles to target the media library upload field. For example:
/* Reverse the order of the images */
.filament-media-library-file-upload-preview-list {
display: flex;
flex-direction: column-reverse;
}
/* Custom styles for the images */
.filament-media-library-file-upload-preview-card {
/* Your custom styles here */
}
2. Overriding Views:
If you need to change the HTML structure, you can publish the views of the Spatie Media Library package and customize them.
First, publish the views:
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="views"
Then, locate the published views in the resources/views/vendor/media-library directory and modify them as needed.
3. Reference a Blade View:
If you want to use a custom Blade view for the display of the media items, you can create a custom component and reference it in your Filament resource.
Create a Blade component, for example, resources/views/components/custom-media-item.blade.php, and then use it in your Filament resource like so:
SpatieMediaLibraryFileUpload::make('images')
->label('Images')
->collection('images')
->multiple()
->reorderable()
->view('components.custom-media-item') // Reference your custom Blade view
In your custom Blade view, you can loop through the media items and display them as you wish.
Including an Image in Markdown:
To include an image in markdown, you can use the following syntax:

Make sure the path to the image is correct and accessible from where the markdown is being rendered.
Remember to clear your cache and recompile your assets if necessary after making changes to CSS or views:
php artisan optimize:clear
npm run dev // or npm run prod for production
By using one of these methods, you should be able to customize the display of the SpatieMediaLibraryFileUpload field to your liking.