Image hyperlink applied in the editor is silently dropped on save (Portable Text image block has no link field)
Summary
A hyperlink applied to an image in the admin editor is silently dropped when the entry is saved. The link appears to work while editing, but it never reaches the stored Portable Text, so it is absent from the public render — and it is also gone if the entry is reopened in the editor.
Version: 0.32.0 (also inspected the 0.32.0 published source; all references below are to that tarball).
Steps to reproduce
- In a
portableTextfield, insert an image into the body. - Select the image and apply a link via the editor's link control. The editor session shows it applied.
- Save/publish the entry.
- View the public page rendered via
<PortableText>— the image renders with no<a>wrapper. - Reopen the entry in the editor — the link is gone there too.
Root cause (from the 0.32.0 source)
The Portable Text image block cannot carry a link, and both converters drop it:
src/content/converters/types.ts—PortableTextImageBlockhas fields forasset,alt,caption,width/height,displayWidth/displayHeight, but no link/href field.src/content/converters/prosemirror-to-portable-text.ts—convertImage()maps onlyprovider,mediaId,src,alt,title, and the four dimension attrs. Any link mark/attr on the image node is discarded on save.src/content/converters/portable-text-to-prosemirror.ts— the reverseconvertImage()likewise restores no link, so the loss is invisible until you look at the published page (or reload the editor).src/components/Image.astro(public renderer) has no link handling either, so even a hand-authored block with an extra field would not render one.
Expected
Either round-trip the link (add e.g. link?: { href: string; blank?: boolean } to PortableTextImageBlock, carry it through both converters, and wrap the rendered <figure>/<img> in an anchor in Image.astro), or disable the link control for image nodes in the editor so the UI doesn't accept input it cannot persist.
Impact
Content editors reasonably use linked images (e.g. a promotional image linking to a signup page). Today the editor accepts the link and everything downstream loses it silently — the failure is invisible at authoring time.
Source: emdash-cms/emdash