medialibrary-development

Manage media files in Laravel with Eloquent associations and conversions.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/mkopcic/laravel-postgresql-demo --skill medialibrary-development-mkopcic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: medialibrary-development
Source: https://github.com/mkopcic/laravel-postgresql-demo/tree/main/.claude/skills/medialibrary-development
Command: npx skills add https://github.com/mkopcic/laravel-postgresql-demo --skill medialibrary-development-mkopcic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires spatie/media-library, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill solves the problem of managing media files in Laravel applications, including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.

Core Features & Use Cases

  • Eloquent Model Media Associations: Attach files to Eloquent models.
  • Collections and Conversions: Define media collections and conversions for responsive images.
  • File Retrieval: Retrieve media URLs and paths for display or processing.
  • Use Case: For a content management system, use this Skill to automatically generate thumbnails and responsive images for uploaded media files, simplifying the frontend display and improving user experience.

Quick Start

Use the medialibrary-development skill to add an image to a blog post by providing the file path to 'addMedia' and specifying the collection name 'images'.

Frequently Asked Questions about medialibrary-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I attach uploaded files to Eloquent models in Laravel?

To attach uploaded files to Eloquent models in Laravel, use the `addMedia` method with a file path and specify a collection name. This associates the media directly with your model records for streamlined file management.

What is the best way to generate responsive images for a Laravel media library?

The best way to generate responsive images in a Laravel media library is by defining media conversions within your Eloquent models. This automatically creates optimized image variants for frontend display.

Does Spatie media library support defining multiple media collections for a single Eloquent model?

Yes, Spatie media library supports defining multiple media collections for a single Eloquent model. You can categorize files by specifying collection names when adding media, such as separating 'images' from 'documents'.

How do I retrieve media URLs and file paths from associated Eloquent models?

To retrieve media URLs and file paths from associated Eloquent models, use the provided retrieval methods after associating files. This allows you to fetch the exact storage locations for display or further processing.

Why are my file uploads not associating correctly with Eloquent models in Laravel?

File uploads may not associate correctly with Eloquent models if the Spatie media library dependencies are missing or improperly configured. Ensure the required packages are installed and you pass a valid file path to `addMedia`.

Can I use this Laravel media management approach for a content management system?

Yes, you can use this Laravel media management approach for a content management system. It simplifies generating thumbnails and responsive images for uploaded files, directly improving frontend user experience.