The media package utilizes Cloudinary for images and YouTube for videos. Create a free Cloudinary account for each Laravel application utilizing this package here:
The following models are included in this package:
List of Models
You can install the package via composer:
composer require drewroberts/media
Add your Cloudinary credentials to your .env file. Choose one of the following options:
Required env variables:
CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@CLOUD_NAME
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_KEY=
CLOUDINARY_SECRET=
FILESYSTEM_DISK=cloudinary
[!NOTE]
You can get your credentials from your Cloudinary console.
Add a cloudinary disk to your config/filesystems.php:
return [
...
'disks' => [
...
'cloudinary' => [
'driver' => 'cloudinary',
'key' => env('CLOUDINARY_KEY'),
'secret' => env('CLOUDINARY_SECRET'),
'cloud' => env('CLOUDINARY_CLOUD_NAME'),
'url' => env('CLOUDINARY_URL'),
'secure' => (bool) env('CLOUDINARY_SECURE', true),
'prefix' => env('CLOUDINARY_PREFIX'),
]
]
];
The package expects
filesystems.disks.cloudinary.cloudto be set. If missing, URL helpers will throw an informative exception.
This package ships with config/media.php for its own options. You can publish and customize it:
php artisan vendor:publish --tag=media-config
Available options and defaults:
return [
'transforms' => [
'cover' => 't_cover',
'cover_placeholder' => 't_coverplaceholder',
],
// Relative path; wrapped with url() in code when no image exists
'fallback_image' => 'img/ogimage.jpg',
// YouTube Data API V3 integration (Non-OAuth)
'youtube' => [
// Set in your application's .env
'api_key' => env('YOUTUBE_API_KEY'),
// HTTP request options
'timeout' => 8.0, // seconds
'base_url' => 'https://www.googleapis.com/youtube/v3',
// Preferred order for selecting thumbnails
'thumbnail_preference' => [
'maxres', 'standard', 'high', 'medium', 'default',
],
],
];
[!NOTE] In your Cloudinary console, create a Named Transformation called
t_coversized to 1200x630 pixels. This package references that name to render cover images.Create another Named Transformation
t_coverplaceholdersized to 120x63 pixels. This is intended as a lightweight loading placeholder, while the fullt_coverimage can be lazy-loaded by the frontend.
This package integrates with the official YouTube Data API v3 using an API key (no OAuth). It is used to parse YouTube links, fetch video details (title, description, duration, publish date, statistics, etc.), and pick the best thumbnail.
Required env variable:
YOUTUBE_API_KEY=
Notes
config/media.php under the youtube key (publish the config if needed).This package ships first‑party Filament resources for managing media:
How they’re registered
DrewRoberts\Media\Filament\Resources.User Resource in your application
php artisan make:filament-resource Customerconfig('auth.providers.users.model') for creator_id and updater_id relations. No additional wiring is required.This package auto-runs its migrations and does not publish them.
The following tables are created:
Note: Because migrations are auto-loaded, you don’t need to vendor:publish them. If you need to customize the schema, override with your own migrations in your application.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
How can I help you explore Laravel packages today?