Skip to content
Extensions
Package

Media library A gallery field backed by spatie/laravel-medialibrary.

ModuleAvailableMIT

One form field that lists a record's media collection, uploads into it and imports images by URL. It is a field, not a second media library: files belong to the record they are attached to.

composer require tbtop/spatie-media-library
Read the docsView on GitHub
[01]What it does

Attach images to a record. One field, one collection.

The model declares a media collection the way spatie documents it; the field binds to that record and collection and handles the rest.

  • One call to configure

    forCollection($record, $collection) is the whole setup — upload endpoints are derived from the page path on the client, so there is nothing to register. Without multiple() the field holds one media id; with it, a list.

    The same field covers a cover image and a gallery.

  • Upload or import by URL

    Files upload from the browser, or are pulled from a URL. Imports run synchronously and re-encode to WebP by default, with the format and quality configurable.

    Moving an existing image in does not mean downloading it first.

  • The upload target is server-side

    The record and collection are read off the field on the re-resolved page, never from the request, and the page's own gate applies. URL import blocks private ranges and non-http schemes with DNS pinning, refuses redirects, stops past the size ceiling and verifies the mime from the downloaded bytes.

    A caller cannot redirect an upload into another model.

[02]Boundaries

What it is not. Read this before installing.

The package is a form field with a deliberately small surface. These are the limits as the code stands, not a roadmap.

01

Is this the admin's media library?

02

Can editors reorder, crop or caption images?

03

What happens when an image is detached?

04

What does it need?

[03]Start

Install it into the admin you already run. MIT, available now.

Both halves install from the same tag. Register the client field once where your admin entrypoint registers the others, declare the collection on the model, and the field is ready. New to tbtop/admin? The field requires it — install it first with composer require tbtop/admin.

Read the docsView on GitHub
composer require tbtop/spatie-media-library

Built by DiVotek · Ukraine