Download the PHP package tbtop/spatie-media-library without Composer
On this page you can find all versions of the php package tbtop/spatie-media-library. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tbtop/spatie-media-library
More information about tbtop/spatie-media-library
Files in tbtop/spatie-media-library
Package spatie-media-library
Short Description Spatie media-library facade for tbtop/admin - collection-scoped image gallery field
License MIT
Informations about the package spatie-media-library
tbtop/spatie-media-library
An image picker for tbtop/admin forms, backed by spatie/laravel-medialibrary. The field lists one record's media collection, uploads into it, and imports images by URL.
It is a field, not a media library. Files belong to the record they are attached to — there is no shared pool, no folders, no cross-entity browsing. For files reused between entities, use the media library that ships with tbtop/admin.
The package is two halves in one repository: the PHP field (src/) and its React client
(client/). Both are required.
Requirements
- PHP 8.4, Laravel 11–13
tbtop/adminand@tbtop/inertia-admin(see peer ranges incomposer.json/client/package.json)spatie/laravel-medialibrary^11
Install
Both halves publish from the same tag, so they cannot drift apart.
Register the client field once, wherever your admin entrypoint registers its other fields:
Register the package for class detection, or its utilities are never generated and the field
renders unstyled. Tailwind skips node_modules unless a source is declared explicitly:
The path is relative to the stylesheet.
Usage
The model needs spatie's contract and a declared collection:
Then bind the field to that record and collection:
forCollection() is the whole configuration. Endpoints are derived from the page path on the
client — nothing to declare, nothing to keep in sync.
Without ->multiple() the field holds a single media id; with it, a list. MediaGalleryOptions::ids()
shapes a collection for the form's record().
The record must be persisted. Spatie derives the storage path from the model key, so attaching to an unsaved model is refused with a 422 rather than writing a row whose path cannot be built.
Uploading and URL import
The field posts to {page-path}/gallery-upload/{field}, registered per panel page. The target record
and collection are read off the field on the re-resolved page and never from the request, so a caller
cannot redirect an upload into another model. The page's own gate applies.
URL import reuses core's guards: private ranges and non-http schemes are blocked with DNS pinning
against rebinding, redirects are refused, the transfer aborts when it exceeds the size ceiling, and
the mime is verified from the downloaded bytes rather than the Content-Type header. Imports run
synchronously and can take as long as the configured timeout.
Configuration
| Key | Default | Meaning |
|---|---|---|
per_page |
24 |
Rows returned per options request |
conversion.format |
webp |
Re-encode format: webp, jpeg, png, or null to keep the original |
conversion.quality |
80 |
Encoder quality |
accept |
['image/*'] |
fnmatch patterns; text/html is refused regardless |
url_import.enabled |
true |
Whether the URL import input is accepted |
The import timeout, size ceiling and host allowlist are read from tbtop-admin.media — one setting
for every ingestion path, rather than a second place to configure the same thing.
Development
client/dist is a build artifact and is not committed: npm builds it from source through
prepublishOnly when publishing, so the checkout never carries one.
client/package.json is the published npm manifest and the single source of truth for the version.
The PHP half has no version of its own — Packagist reads it from the git tag.
Releasing
Bump the version in client/package.json and merge that to main, then run the Release workflow
from main. It publishes the client to npm, pushes the vX.Y.Z tag that Packagist turns into the
PHP release, and creates a GitHub Release with notes generated from the merged pull requests.
npm is published before the tag is pushed, so a failed publish leaves no dangling tag and a re-run stays clean.
All versions of spatie-media-library with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/laravel-medialibrary Version ^11.0
spatie/laravel-package-tools Version ^1.16
tbtop/admin Version ^0.6.1