---
title: "Media Library for Laravel — docs | Roundly"
description: "Developer docs for Media Library for Laravel: buckets, multi-disk storage, image variants, responsive srcset, LQIP placeholders, streaming and CDN URLs."
url: https://roundly-consulting.com/open-source/docs/media-library-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Media Library for Laravel

Install

`composer require roundly-consulting/media-library-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/media-library-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/media-library-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

A native media library for Laravel. Attach files to your Eloquent models in named buckets, or store global media with no owner — all in one polymorphic media table, stored through Laravel's own filesystem on any disk you configure. It handles everything after the upload: image variants, responsive srcset, blur-up placeholders, private streaming, deduplication and CDN URLs. Built only on official Laravel and Symfony dependencies plus the Roundly package toolkit — no third-party media or image vendors.

### What you get

#### Buckets & global media

Attach files to named buckets on any model, or store ownerless global media — all in one polymorphic table.

#### Multi-disk storage

Any Laravel disk, with separate disks for originals and variants — keep originals cold, variants hot.

#### Image variants

Native image-only derivatives via ext-imagick with a GD fallback. Sync by default, queue opt-in.

#### Responsive & LQIP

ThumbHash + Blurhash blur-up placeholders and ready-made responsive srcset helpers.

#### Private URLs & streaming

One temporaryUrl() API that presigns natively — for a separate public origin too — or falls back to a signed streaming route.

#### Dedup & CDN-ready

Content-addressable storage with refcount-guarded deletes, plus a pluggable CDN URL generator.

#### Safe remote fetches

Fetch, vet or validate user-supplied URLs through the same SSRF guard as addFromUrl(), with retryable and terminal errors kept apart.

#### Facade, DI or actions

One MediaLibrary facade, an injectable manager or single-purpose actions — plus a recording fake that touches no disk.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/installation.md)

Install via Composer, publish the migration, and optionally publish the config and the streaming route file.

#### [Configuration](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/configuration.md)

Every config key and its default — disks, image driver, remote fetches, dedup, placeholders, responsive and CDN.

#### [Buckets](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/buckets.md)

Declare named media buckets on a model — disks, mime allowlist, visibility, fallbacks and variants.

#### [The MediaLibrary facade](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/facade.md)

Tour the MediaLibrary facade — global adds, the for($model) handle, move/copy/replace/delete, drafts, attach, variants and rules.

#### [DI and actions](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/without-facade.md)

Skip the facade: inject MediaLibraryManager or call a single-purpose action — the facade method → action map.

#### [Adding media](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/adding-media.md)

Add files from uploads, requests, URLs, disks, strings, base64 or streams through MediaLibrary::for() and the PendingFileAdd builder.

#### [Upload safety](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/upload-safety.md)

Every name and type that reaches storage is untrusted — mime sniffing, safe file names, honest extensions and guarded remote fetches.

#### [Remote URLs](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/remote-urls.md)

Fetch, vet or validate user-supplied URLs with the SSRF guard behind addFromUrl() — MediaLibrary::remote(), SafeRemoteUrl and retryable errors.

#### [Reading media](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/reading-media.md)

Read an owner's media through MediaLibrary::for() — collections, first media, URLs and temporary URLs — plus attributes.

#### [Global media](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/global-media.md)

Store ownerless, app-wide assets — logos, shared PDFs — through the MediaLibrary facade.

#### [Image variants](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/image-variants.md)

Declare resized/reformatted derivatives that generate automatically; control sizing, format, quality and disk.

#### [Responsive images](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/responsive-images.md)

Generate a width ladder and get ready-made srcset and a full <img> tag with an LQIP background.

#### [Placeholders (LQIP)](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/placeholders.md)

ThumbHash and Blurhash blur-up placeholders, plus recorded pixel dimensions, computed on add.

#### [URLs, streaming & downloads](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/urls-streaming.md)

Public URLs, presigned temporary URLs for private media — signed for a separate public origin if needed — and a range-aware streaming route.

#### [Deduplication & integrity](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/deduplication.md)

Content-addressable storage with refcount-guarded deletes that stay safe under concurrent writes, plus an optional read-time checksum check.

#### [Artisan commands](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/commands.md)

Regenerate variants, clean orphaned files, clear buckets, verify checksums and prune expired drafts.

#### [Testing](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/testing.md)

MediaLibrary::fake() records adds, moves and deletes without a disk, fakeDns() answers the URL guard’s DNS — or test end-to-end with Storage::fake().

#### [Requirements](https://roundly-consulting.com/open-source/docs/media-library-for-laravel/requirements.md)

PHP 8.4+, Laravel 12 or 13, ext-fileinfo, Imagick or GD for variants, ext-curl for URL fetches, optional ext-intl and S3 stack, the Roundly toolkit.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
