Hi Jesper,
Maybe I understand your question correctly . I’ve implemented this in a custom package where I used the media picker).
- Import the component:
import type { UmbInputMediaElement } from '@umbraco-cms/backoffice/media';
- Use it inside your Lit template:
<umb-input-media
.selection=${this.media}
.min=${1}
.max=${1}
@change=${this.#onMediaChange}>
</umb-input-media>
- Handle the change event like :
#onMediaChange(event: CustomEvent & { target: UmbInputMediaElement }) {
this.media = event.target.selection?.join(',') ?? null;
this.dispatchEvent(new UmbPropertyValueChangeEvent(this.media));
}
It works well with the Umbraco backoffice experience. Also:
- You can use a similar approach with
umb-input-document
for content pickers. - Use
.min
and.max
to control selection limits.
Let me know if you’d like me to share a working snippet or more code from my package