- How do I upload files with Laravel MediaMan and attach them to a model?
- Use the fluent `MediaUploader` to handle file uploads independently of models. After uploading, attach the media to a model using the `attachMedia()` method with a channel name (e.g., `avatar` or `gallery`). Example: `$media = MediaUploader::fromRequest('file')->upload(); $user->attachMedia($media, 'avatar');`.
- Does Laravel MediaMan support responsive images (WebP, AVIF, etc.)?
- Yes, MediaMan generates responsive images automatically when enabled. Use `media()->getPictureHtml()` to output `<picture>` tags with multiple formats (WebP, AVIF, JPG) and sizes. Disable auto-generation (`auto_generate: false`) if you prefer manual control to optimize performance.
- Can I use Laravel MediaMan with Laravel 12 or 13?
- MediaMan is designed for Laravel 12/13 and supports all modern features. No breaking changes are expected, but always check the [GitHub repo](https://github.com/emaia/laravel-mediaman) for compatibility notes. The package follows Laravel’s conventions closely.
- How do I organize media into collections or libraries?
- MediaMan uses virtual collections to group files logically. Assign a collection name during upload (e.g., `useCollection('product-images')`) or later via the `Media` model. Collections are stored in the `mediaman_collections` table and can be managed independently of model associations.
- What storage drivers does Laravel MediaMan support?
- MediaMan works with any Laravel-supported storage driver (local, S3, FTP, etc.). Configure the default disk in `config/filesystems.php` or specify a custom disk per upload. Ensure your storage adapter is properly set up, as MediaMan relies on Laravel’s filesystem integration.
- How do I handle image processing (resizing, watermarks) with MediaMan?
- Define conversions globally using `Conversion::register()` for tasks like resizing or watermarking. These run automatically when media is attached to a model via a channel. Conversions are queueable, so CPU-heavy tasks (e.g., large image resizing) won’t block requests. Requires `imagick` or `gd` PHP extensions.
- Is Laravel MediaMan compatible with other media packages like spatie/laravel-medialibrary?
- MediaMan is designed to be standalone and doesn’t conflict with other packages. However, avoid mixing it with similar libraries (e.g., spatie/medialibrary) in the same project, as they may use overlapping database tables or configurations. Choose one based on your needs.
- How do I validate file uploads (size, MIME types) in MediaMan?
- MediaMan doesn’t enforce validation itself; use Laravel’s built-in validation (e.g., `FormRequest`) to check file sizes, types, or extensions before upload. Configure allowed MIME types and extensions in your request logic, as MediaMan relies on upstream validation for security.
- Can I use MediaMan for video or audio files, or is it image-focused?
- MediaMan primarily supports image processing via Intervention/Image (resizing, formats). For videos/audio, it handles storage and associations but lacks built-in transcoding. Use it for metadata-heavy media or pair it with FFmpeg for advanced processing.
- What’s the best way to test Laravel MediaMan in production?
- Start with a proof-of-concept: test uploads, model associations, and responsive images in staging. Monitor queue workers (`php artisan queue:work`) for conversion jobs, and benchmark performance with large files. Use `php artisan mediaman:prune` to clean up test media and avoid storage bloat.