codprez/laravel-media-library

Media library with upload, variants, and selector UI for Laravel + Inertia + React.

Maintainers

Package info

github.com/obalaweb/laravel-media-library

Language:TypeScript

pkg:composer/codprez/laravel-media-library

Statistics

Installs: 103

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.2.0 2026-04-14 11:11 UTC

This package is auto-updated.

Last update: 2026-04-14 11:12:08 UTC


README

A robust media library management system for Laravel applications using Inertia.js and React. It provides a full-featured media manager with upload capabilities, variants (thumbnails), and a selector UI.

Features

  • Media Management: Upload, rename, and delete media files.
  • Variant Generation: Automatic generation of thumbnails and webp variants (expandable).
  • Inertia/React Integration: Ready-to-use components for selecting and managing media in your admin panel.
  • Filtering: Filter media by type (image, video, document) and search by name.
  • Multi-delete: Select and remove multiple files at once.

Requirements

  • PHP 8.2+
  • Laravel 12.x | 13.x
  • Inertia.js (React)

Installation

You can install the package via composer:

composer require codprez/laravel-media-library

Publish Configuration and Migrations

php artisan vendor:publish --tag="media-library-config"
php artisan vendor:publish --tag="media-library-migrations"

Run Migrations

php artisan migrate

Configuration

The configuration file is located at config/media-library.php. Here you can define the user model for relationships:

return [
    'user_model' => \App\Models\User::class,
];

Usage

Backend

The package provides a Media model and a MediaController. By default, it uses the public disk for storage.

Handling Uploads

The MediaController includes a store method that handles file uploads and automatically generates metadata.

// In your routes/web.php or routes/api.php
use Codprez\MediaLibrary\Http\Controllers\MediaController;

Route::post('/admin/media', [MediaController::class, 'store'])->name('admin.media.store');

Frontend (Inertia + React)

The package includes React components located in resources/js. You can import and use them in your Inertia pages.

Component Example

import { MediaSelector } from 'codprez/laravel-media-library';

function MyForm() {
    return (
        <MediaSelector 
            onSelect={(media) => console.log(media)}
            multiple={false}
        />
    );
}

License

The MIT License (MIT). Please see License File for more information.