drpshtiwan/livewire-media-selector
A lightweight, WordPress-style media selector for Laravel applications powered by Livewire.
Full documentation: livewire-media.thejano.com

gallery, avatars)attachMedia, syncMedia, getMediaUrl) for quick model integrationcan_upload config and :canUpload attribute to disable Upload tab and uploadsNote: Laravel 11 and earlier are not supported — Laravel 11 reached its security-fix end-of-life in March 2026. For older Laravel versions, use the 1.x line of this package.
Require the package:
composer require drpshtiwan/livewire-media-selector
Publish the config (optional):
php artisan vendor:publish --tag=media-selector-config
Publish the migration and run it:
php artisan vendor:publish --tag=media-selector-migrations
php artisan migrate
Ensure your public disk is set up and linked:
php artisan storage:link
Publish the views (optional, if you want to customize the markup/classes):
php artisan vendor:publish --tag=media-selector-views
Publish the assets (CSS):
php artisan vendor:publish --tag=media-selector-assets --force
Simple usage:
<livewire:media-selector wire:model="media" collection="gallery" />
Read the docs for setup details, configuration options, and integration patterns.
The selector enforces a clear trust boundary between what the server controls and what the browser may change:
canDelete, canUpload, canSeeTrash, canRestoreTrash, restrictToCurrentUser, the allowed file types (mimes/extensions), the storage disk/directory, and upload limits are #[Locked] Livewire properties. They are resolved once in mount() from the attributes you pass and from config; a crafted Livewire request cannot flip a permission, widen the allowed file types to smuggle an executable upload, or repoint the storage location.:can-delete="auth()->user()?->can('delete', $model)". The package will not grant an action you did not enable.<script>/event handlers, so serving them from a public disk by URL is a stored-XSS vector. They are omitted from the default allowed_extensions; if you re-enable them, sanitize uploads (e.g. enshrined/svg-sanitize) or serve them with Content-Disposition: attachment / a restrictive CSP. Note the image/* MIME wildcard also matches image/svg+xml.See CHANGELOG.md for recent and upcoming changes.
Developed and maintained by drpshtiwan.
MIT License. See LICENSE for details.
How can I help you explore Laravel packages today?