Skip to main content
Spatie Media Library is optional. Use it when your attachments belong to Eloquent models and you want its collection and conversion APIs. Disk-only Media OS usage does not require these packages.

Do I need another table for website or API previews?

Normally, no. Spatie already relates each original media row to its model and records which named conversions have been generated. Retrieve a thumbnail with getUrl('thumb'), checking hasGeneratedConversion('thumb') when conversions run in a queue. A converted file does not need its own additional gallery row, and the field does not require a JSON path column on the parent model. These images can be used outside Filament without mounting a FLEX field. See the complete Spatie JSON endpoint and website guidance. Skip the native gallery_conversions table and indexer in that guide when using Spatie. An extra SQL index is only an application-specific reporting/query choice, not a requirement for normal display or API use.

Install optional dependencies

Follow Spatie’s installation instructions. For FLEX form fields, also install Filament’s matching Spatie Media Library plugin version.
Publish the Media Library configuration/migrations and migrate according to the versions installed in your application. Configure the media table, image driver and queue before using the integration.

Model setup

Store through Media OS

Use a persisted HasMedia model. For an unsaved create record, stage first or let the FLEX field manage create-form timing.

FLEX form field

The field uses owned Media UUIDs while the disk field uses paths. You do not need a photos path column when using the Spatie relationship integration. Factory shorthand:

Different disks for originals and conversions

An explicit disk takes precedence over the collection disk. Conversion storage is configured independently.

Custom properties and display name

Properties are application metadata; they do not edit image EXIF. The optional FLEX information editor uses custom_properties.editorial for its own document.

Responsive images

You can also define responsive images on native collections/conversions. For your frontend templates, use Spatie’s srcset/rendering APIs. The FLEX preview selects its configured conversion; responsive-image generation does not automatically replace the field’s preview with a full responsive <img> API.

Native FileAdder configuration

The callback configures the adder. Do not call toMediaCollection() inside it or change the source/record identity; Media OS owns that persistence step. Custom Media models, path generators, file namers and URL generators remain native Spatie configuration. For a field callback, preserve its collection:
This replaces the options object; explicitly retain any other defaults you need.

Queued conversions

In config/media-library.php:
Spatie conversion jobs use the native Media Library queue configuration. SpatieOptions::queue configures the FileAdder’s responsive-image job queue, not a replacement for the conversion queue configuration. Before a selected conversion is generated, FLEX shows an available original preview. The list indicates processing; the field refreshes pending previews without refreshing the whole page. Native Spatie failed jobs are diagnosed/retried through Laravel’s queue tools; a missing conversion alone is not treated as proof of a permanent failure. Do not enable native imageConversions() or queueImageConversions() on this field; use Spatie’s model conversion API.

Retrieve and update native media

For private links, use Media OS’s authorized URL API:
Missing conversions can fall back to the original. Private links require a signing-capable disk or configured URL provider.

Move, copy and order

Native operations remain available on your owned model/media objects:
Authorize both records and the supplied media IDs in your application before invoking native operations. In a FLEX field, reorderable() supplies the form’s drag-sorting behavior.

Removing originals

Spatie normally retains the stored original and creates conversions alongside it. It has no standard conversion setting for “delete the original after large and thumb complete”. preservingOriginal() controls whether importing a local file copies or moves that input; it does not remove the library’s original. See associating files and conversion optimization. Store a normalized smaller master when you do not want to retain the full upload. Manually deleting the stored original would break original URLs, fallback and regeneration. The native Media OS engine also retains originals.

Option reference

Save behavior

Collection constraints and native Spatie events/conversions remain authoritative. FLEX staging defers destructive replacement until record acceptance. Object storage and database changes are separate operations; an interrupted save can require reconciliation. Use field lifecycle hooks when replacing the usual Filament save flow.
Last modified on October 17, 2026