MCPcopy
hub / github.com/directus/directus / onMediaSelect

Function onMediaSelect

app/src/interfaces/input-rich-text-html/useMedia.ts:171–183  ·  view source on GitHub ↗
(media: Record<string, any>)

Source from the content-addressed store, hash-verified

169 }
170
171 function onMediaSelect(media: Record<string, any>) {
172 const sourceUrl = getPublicURL() + 'assets/' + media.id;
173 const tag = media.type.startsWith('audio') ? 'audio' : 'video';
174
175 mediaSelection.value = {
176 sourceUrl: replaceUrlAccessToken(sourceUrl, imageToken.value),
177 width: media.width || 300,
178 height: media.height || 150,
179 tag,
180 type: media.type,
181 previewUrl: replaceUrlAccessToken(sourceUrl, imageToken.value),
182 };
183 }
184
185 function saveMedia() {
186 editor.value.fire('focus');

Callers

nothing calls this directly

Calls 2

getPublicURLFunction · 0.90
replaceUrlAccessTokenFunction · 0.70

Tested by

no test coverage detected