medialibrary-development

Attach files to Eloquent models using spatie/laravel-medialibrary.

Updated Dec 19, 2025
One-click install
npx skills add https://github.com/beardcoder/mens-circle --skill medialibrary-development-beardcoder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: medialibrary-development
Source: https://github.com/beardcoder/mens-circle/tree/main/.agents/skills/medialibrary-development
Command: npx skills add https://github.com/beardcoder/mens-circle --skill medialibrary-development-beardcoder

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Laravel developers manage media files with spatie/laravel-medialibrary by linking files to models, organizing collections, and generating conversions and URLs.

Core Features & Use Cases

  • Attach files to Eloquent models using HasMedia and InteractsWithMedia.
  • Define media collections and conversions, including responsive images and custom properties.
  • Retrieve media URLs, paths, and metadata for display or download in user applications.

Quick Start

Attach a sample image to a BlogPost model and retrieve its URL.

Frequently Asked Questions about medialibrary-development

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

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

To attach media files to Eloquent models in Laravel, you implement the HasMedia and InteractsWithMedia interfaces to link files directly to your database records using spatie/laravel-medialibrary workflows.

How do I define media collections and conversions for responsive images in Laravel?

Defining media collections and conversions in Laravel involves specifying image transformations within your model setup to automatically generate responsive images and custom properties upon file attachment.

Can I retrieve media URLs and metadata from Eloquent models for display?

Yes, you can retrieve media URLs, file paths, and metadata from Eloquent models. The medialibrary provides retrieval patterns to easily access generated conversion URLs for display or download in applications.

What is the best way to organize media attachments across different Laravel model types?

Organizing media attachments across Laravel model types is best handled by defining distinct media collections within each model, allowing you to categorize files and apply specific conversions per collection.

Do I need to configure custom properties when attaching media to Laravel models?

Configuring custom properties when attaching media to Laravel models is optional but useful. It allows you to store additional metadata alongside the file within the medialibrary for later retrieval and filtering.