Filament Plugins

Purchase

Media Library Item-driver

The MediaLibraryItemDriver allows you to combine the best of Spatie Media Library with the flexibility of re-using media items across models. Furthermore, storing media items is as easy as storing just a single ID.

Pros

  • Image/PDF conversions built-in.
  • Proven technology & scalability with over 28 million installs.
  • Can handle non-unique file names easily.
  • Easy response-image integration for use on (Blade-based) frontends.
  • Link selected images to your models using a database ID and foreign key.
  • More performant searching through large libraries.

Cons

  • Storing a selection of multiple MediaLibraryItem's can be done using a JSON-column with integer IDs or a separate pivot table, which is less intuitive.

Installation

1

Install Spatie Media Library package

To use the MediaLibraryItemDriver, you need to install the Spatie Media Library package and follow the instructions in the Spatie Media Library documentation:

terminal

composer require spatie/laravel-medialibrary

Next, publish and run the package migrations:

terminal

php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
2

Review disk

The Spatie Media Library stores all media on a disk. By default, this is the public disk. It is recommended to verify the disk before storing any media:

.env

MEDIA_DISK=s3
3

Configure driver

The MediaLibraryItemDriver is the default driver of the Media Library, so it doesn't need to be specifically enabled.

That's it! You now have a fully functional Media Library running Spatie Medialibrary as a driver.

© FilamentPlugins.com ✦ 2022 – 2025 ✦ All rights reserved.