Skip to content

MediaValue.src contains bare media ID instead of URL #696

Closed

Description

@Vallhalen

Bug

When an image field (type image) is stored in a content entry, the MediaValue object has the media reference ID in the src field instead of a resolved URL:

{
  "provider": "local",
  "id": "",
  "src": "01KPD97MWB5DVHBHK69TW55KY3"
}

Expected

Either:

  • id should contain the media reference ID and src should be empty/undefined (or a resolved URL)
  • Or src should contain a usable URL like /_emdash/api/media/file/01KPD97MWB5DVHBHK69TW55KY3

Actual

  • id is an empty string ""
  • src contains the bare ULID "01KPD97MWB5DVHBHK69TW55KY3" (not a URL)

Impact

Any code that reads MediaValue.src and treats it as a URL (which is reasonable given the field name) will output the bare ID. This affects:

  1. Schema/JSON-LD — BlogPosting.image gets the bare ID instead of a URL, breaking Google rich results validation
  2. og:image meta tags — same issue, social cards show broken images
  3. Any template that manually reads entry.data.hero_image.src expecting a URL

Workaround

We currently detect bare IDs in src and manually resolve them:

if (img?.src) {
  if (img.src.startsWith("http")) return img.src;
  if (img.src.startsWith("/")) return `${origin}${img.src}`;
  return `${origin}/_emdash/api/media/file/${img.src}`;
}

Environment

  • EmDash 0.4.x
  • Astro 6 + Cloudflare Workers
  • Content created through EmDash admin UI (not imported)

Notes

The EmDashImage component handles this correctly internally via buildLocalImageUrl() which falls back from meta.storageKey to id. But external consumers of MediaValue (like schema generation or og:image) don't have that logic and reasonably expect src to be a URL.

Activity

  1. added
    bug
    on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/corebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions