Skip to content

Input Field ​

<x-mediaflow-input> turns any form field into an upload box. It supports drag-and-drop and file browsing, uploads immediately, shows a preview card with Open, Copy URL, Replace and Remove buttons, and offers a picker to choose an existing file from the library. The form submits the media ID in a hidden input.

blade
<x-mediaflow-input
    name="cover_media_id"
    label="Cover image"
    help="Drag and drop an image or pick one from the library."
    :required="true"
/>

<x-mediaflow-input> and <x-mediaflow::input> are the same component.

Options ​

OptionTypeDefaultDescription
namestringrequiredName of the hidden input that carries the media ID.
labelstringnullLabel above the field.
helpstringnullHelper text below the field.
requiredboolfalseShows the required marker and sets required on the field.
valueMedia, int or stringnullInitial value: a Media model, a media ID or a URL. Shows the preview card.
typestringimageFile preset: image, video, audio, doc / docs / pdf, or any / *. Sets the accepted types, icon, helper text and picker filter. types is an alias.
acceptstringfrom typeCustom accept list, e.g. .pdf,.docx or video/*.
folderstringnullFolder ID, name or path (e.g. blog/covers) for new uploads. Missing folders are created.
collectionstringdefaultCollection name stored with each upload.
visibilitystringpublicpublic or private. Private files get signed URLs.
compactboolfalseSmaller layout for sidebars and drawers (about 280–340 px wide).
pickerbooltrueShow the "Browse library" button.
upload-onlyboolfalseHide the library picker. :browse="false" and :hide-browse="true" do the same.
frontendboolfalseLock the picker to folder and collection and hide admin folders. :isolated="true" is an alias.
picker-scopestringall, or frontend when frontend is onScope passed to the picker.
open-tabbooltrueShow the Open button on the preview card.
copy-urlbooltrueShow the Copy URL button on the preview card.
pipelineboolui.show_pipeline (on)Show the animated upload pipeline while uploading. visualizer is an alias.
upload-urlstringroute('mediaflow.upload')Send uploads to a different endpoint.
themestringsettingsAccent preset for this field; see Theming.
modestringsettingslight, dark or system for this field.
folder-colorstringsettingsHex colour for folder icons in the picker.

Any other attributes, such as class or id, are added to the wrapper element.

File types ​

blade
{{-- Video: MP4, WebM, Ogg, QuickTime --}}
<x-mediaflow-input name="trailer_id" label="Trailer" type="video" folder="videos" />

{{-- Documents: PDF, Word, Excel, PowerPoint, text, CSV --}}
<x-mediaflow-input name="contract_id" label="Signed contract" type="docs" accept=".pdf,.docx" />

{{-- Audio: MP3, WAV, Ogg --}}
<x-mediaflow-input name="episode_id" label="Episode audio" type="audio" folder="podcasts" />

{{-- Anything allowed by the server --}}
<x-mediaflow-input name="attachment_id" label="Attachment" type="any" />

The accept list only filters what the browser offers. The server still applies the upload rules, so make sure the types you want are in allowed_mimes.

Editing existing records ​

blade
<x-mediaflow-input
    name="cover_media_id"
    label="Cover image"
    :value="$post->cover ?? old('cover_media_id')"
/>

Public forms ​

For forms used by customers or guests, keep them away from the admin library:

blade
{{-- Upload only --}}
<x-mediaflow-input name="avatar_id" label="Profile photo" :upload-only="true" />

{{-- Picker locked to one folder and collection --}}
<x-mediaflow-input name="avatar_id" label="Profile photo"
    :frontend="true" folder="user-avatars" collection="avatars" />

For real separation between users, also turn on per-user scoping. Picker restrictions are a convenience in the UI; scoping is enforced on the server.

Use compact in narrow panels:

blade
<aside style="width: 320px">
    <x-mediaflow-input name="thumbnail_id" label="Thumbnail" :compact="true" />
</aside>

The picker and pipeline modals are attached to document.body with a very high z-index, so overflow: hidden, transform or filter on a parent panel cannot clip them.

Browser events ​

The field dispatches bubbling DOM events you can listen to:

Eventevent.detailWhen
mediaflow:change{ media }A file was uploaded or picked and the field now has a value.
mediaflow:removednoneThe user removed the current file.
js
document.addEventListener('mediaflow:change', (e) => {
  console.log('New media ID', e.detail.media.id)
})

See Events for all PHP and browser events.

Released under the MIT License.