Attached images cause error in backlinks buffer

When rendering the backlinks buffer, if the content to render contains any attached images, Org can’t seem to find them and falls back to rendering the filename as a base64 string, which obviously fails with Invalid base64 data (since it’s not base64 data). As a result, the rendering stops there and the remaining backlinks don’t get shown.

I’m currently using the following workaround to turn the error into a non-fatal one, which is basically a slightly tweaked version of this commit:

(defadvice! no-errors/+org-inline-image-data-fn (_protocol link _description)
  :override #'+org-inline-image-data-fn
  "Interpret LINK as base64-encoded image data. Demote errors to warnings."
    "Error rendering inline image (parent node ID changed or Org-roam backlink buffer?): %S"
    (base64-decode-string link)))

This works, but I’m still curious – are other people also experiencing this? Or is my setup somehow wrong? The root cause seems to be that the proper attachment directory can’t be inferred in the backlinks buffer, maybe because the Org ID of the parent node can’t be retrieved in that context, or maybe because I’m using Doom Emacs, which sets a global attachment directory, which may go against some hardcoded expectations that Org-roam might have…

Any tips or reports of your own experiences with images in the backlinks buffer are appreciated :slight_smile: I don’t really mind having no images in the backlinks buffer (which is what my current workaround results in), but I do mind it being truncated.

Is this a Doom-specific issue?

I just tried with Emacs with no config (other than MELPA-Stable) and installed Org-roam v2.2.0 via MELPA-Stable.

The left is the main node entitled “first”. The right is org-roam-buffer with backlinks preview shown for “first”. The second preview entry has a link to an image.

Even though org-roam-buffer is not even an Org mode buffer, I can toggle the inline image.

I don’t think I have images shown in my backlinks previews – I have never paid attention and did not notice until your post :wink:

Thanks a lot for your quick reply, and apologies for my late one – my wife went into labor in the meantime :slight_smile:

Thank you for testing this with a vanilla setup! In that case, it looks like it might be a Doom-specific issue, that’s good to know. Unless it’s Org-roam relying on a default setting in Orgmode that Doom changes.

(One such thing is that Doom configures a global attachment directory via org-attach-id-dir.)

I’ll try and investigate further and report it – if I get a bit of time in the upcoming days (which is not very likely though – see above).