How to display images in a dynamic content macro's body

I’ve got a dynamic content macro with a body. I convert the body by first receiving it in storage format from rest/api/content/${pageId}/history/${pageVersion}/macro/id/${macroId}. Then I convert it from storage to view by using rest/api/contentbody/convert/view with the following payload:

{
    value: myMacrosBody,
    representation: 'storage'
}

This seems to convert everything fine so far, but images are not converted. Instead they return “Unknown Attachment”, it looks like this:unknown-attachment

How do I get my images to display correctly? Is this a bug in the API? Everything else seems to work just fine.

Here’s the content of my macro’s body in storage format:

<ac:image ac:align="center" ac:layout="center" ac:original-height="320" ac:original-width="321">
    <ri:attachment ri:filename="tiktok-cute-aww" ri:version-at-save="2"></ri:attachment>
</ac:image>

When sending this to the convert endpoint, I receive this:

<span class="confluence-embedded-file-wrapper image-center-wrapper">
    <img class="confluence-embedded-image image-center" src="https://my-confluence.atlassian.net/wiki/plugins/servlet/confluence/placeholder/unknown-attachment?locale=en_GB&amp;version=2">
</span>

Any help is appreciated, thank you!
Also it doesn’t matter if I do this from my frontend with the AP.request or from my backend. Both result in the same outcome, however, with staticContentMacros this seems to work fine for me…

You probably need to rewrite ri:attachment elements to contain a child ri:page element with attributes ri:space-key and ri:content-title.

2 Likes

Ouch, that’s a bummer.

Anyway, thank you sir :slight_smile:

1 Like