|
1 | 1 | # Livewire Media Uploader |
2 | 2 |
|
3 | | -Reusable **Livewire v3** media uploader with **TailwindCSS** UI, Alpine-powered overlays, and first-class integration with **Spatie Laravel Media Library**. Ships with a **publishable Blade view** so each app can theme it as needed. |
| 3 | +Livewire Media Uploader is a reusable Livewire v3 component that integrates seamlessly with Spatie Laravel Media Library. It ships a clean Tailwind Blade view (fully publishable), Alpine overlays for previews and confirmations, drag-and-drop uploads, per-file metadata (caption/description/order), configurable presets, name-conflict strategies, and optional SHA-256 duplicate detection. Drop it in, point it at a model, and you’re shipping in minutes. |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
@@ -78,21 +78,59 @@ The component is registered under **both** aliases: |
78 | 78 |
|
79 | 79 | ## Publishing Assets |
80 | 80 |
|
81 | | -**Config:** |
| 81 | +### Config: |
82 | 82 | ```bash |
83 | 83 | php artisan vendor:publish --tag=media-uploader-config |
84 | 84 | ``` |
85 | 85 |
|
86 | | -**Views:** |
| 86 | +### Views: |
87 | 87 | ```bash |
88 | 88 | php artisan vendor:publish --tag=media-uploader-views |
89 | 89 | ``` |
90 | 90 |
|
91 | 91 | After publishing, customize the Blade at: |
92 | | -``` |
| 92 | +```html |
93 | 93 | resources/views/vendor/media-uploader/livewire/media-uploader.blade.php |
94 | 94 | ``` |
95 | 95 |
|
| 96 | + |
| 97 | +## Environment variables (optional) |
| 98 | +You can override preset limits and accepted types/mimes via .env. These map directly to config/media-uploader.php: |
| 99 | + |
| 100 | +```dotenv |
| 101 | +# Livewire Media Uploader (optional) |
| 102 | +
|
| 103 | +# Images |
| 104 | +MEDIA_TYPES_IMAGES=jpg,jpeg,png,webp,avif,gif |
| 105 | +MEDIA_MIMES_IMAGES=image/jpeg,image/png,image/webp,image/avif,image/gif |
| 106 | +MEDIA_MAXKB_IMAGES=10240 |
| 107 | +
|
| 108 | +# Documents |
| 109 | +MEDIA_TYPES_DOCS=pdf,doc,docx,xls,xlsx,ppt,pptx,txt |
| 110 | +MEDIA_MIMES_DOCS=application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,text/plain |
| 111 | +MEDIA_MAXKB_DOCS=20480 |
| 112 | +
|
| 113 | +# Videos |
| 114 | +MEDIA_TYPES_VIDEOS=mp4,mov,webm |
| 115 | +MEDIA_MIMES_VIDEOS=video/mp4,video/quicktime,video/webm |
| 116 | +MEDIA_MAXKB_VIDEOS=102400 |
| 117 | +
|
| 118 | +# Fallback preset |
| 119 | +MEDIA_TYPES_DEFAULT=jpg,jpeg,png,webp,avif,gif,pdf,doc,docx,xls,xlsx,ppt,pptx,txt |
| 120 | +MEDIA_MIMES_DEFAULT=image/jpeg,image/png,image/webp,image/avif,image/gif,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,text/plain |
| 121 | +MEDIA_MAXKB_DEFAULT=10240 |
| 122 | +``` |
| 123 | + |
| 124 | +### Notes |
| 125 | +- Values are comma-separated; spaces are OK (the package trims them). |
| 126 | +- After changing .env, run: |
| 127 | +```bash |
| 128 | +- php artisan config:clear |
| 129 | +# (or) php artisan config:cache |
| 130 | +``` |
| 131 | +- The `````<input accept="…">````` attribute is auto-filled from the active preset when accept_from_config is true (default). You can still override it per-component with the accept prop. |
| 132 | +- If uploads fail due to size, make sure your PHP/Server limits also allow it (e.g. upload_max_filesize, post_max_size). |
| 133 | + |
96 | 134 | --- |
97 | 135 |
|
98 | 136 | ## Quick Start |
@@ -334,16 +372,16 @@ class User extends Model implements HasMedia |
334 | 372 |
|
335 | 373 | ## Roadmap |
336 | 374 |
|
337 | | -- Drag-to-reorder (update `order_column`) |
338 | | -- Optional queued conversions hints |
| 375 | +- Drag-to-reorder (update `order_column`). |
| 376 | +- Show document icon instead of thumbnail in Attached media list if the file is not an image. |
339 | 377 |
|
340 | 378 | PRs welcome! |
341 | 379 |
|
342 | 380 | --- |
343 | 381 |
|
344 | 382 | ## License |
345 | 383 |
|
346 | | -**MIT** © Ray Cuzzart II |
| 384 | +**MIT** © CodebyRay (Ray Cuzzart II) |
347 | 385 |
|
348 | 386 | --- |
349 | 387 |
|
|
0 commit comments