Looking to hire Laravel developers? Try LaraJobs

laravel-media-library maintained by codprez

Description
Media library with upload, variants, and selector UI for Laravel + Inertia + React.
Author
Last update
2026/04/28 09:02 (dev-main)
License
Links
Downloads
154

Comments
comments powered by Disqus

Laravel Media Library

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 10.x | 11.x | 12.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.