Documentation / @zerotal/admin / index / resolveMediaSrc
Function: resolveMediaSrc()
resolveMediaSrc(
value,disk?):string|null
Defined in: admin/src/media.ts:174
Turn a stored value into something an <img src> can fetch.
Image columns and entries hold whatever the record holds, and that is one of
three things: a full URL from an external service, a root-relative path the
app already serves, or a disk-relative storage path like media/photo.jpg.
Only the last needs resolving — and rendering it unresolved is the bug this
exists to prevent, because a browser reads media/photo.jpg relative to the
page and fetches /admin/shop/media/photo.jpg, which is the panel's own 404.
Synchronous, because cells and entries render synchronously. That is possible
for a plain public disk, where a URL is a prefix and a path. It is not for a
signed disk, whose URL has to be minted per request — those return null and
the caller shows a placeholder. Put images meant for a table on a public disk.
Parameters
value
unknown
disk?
string
Returns
string | null
The URL, or null when there is none to give.