How to get the cover picture URL?

Users can choose a cover/title image for blog posts. Either by selecting an Unsplash image or by uploading a custom image. I want to display these images in a macro.

When searching for blog posts by using requestConfluence("/wiki/rest/api/content/search?cql=..."), I can expand metadata.properties.cover_picture_id_published to get information about the cover image.

If it is an Unsplash image, metadata.properties.cover-picture-id-published.value.id contains the image URL – great. But if it is an uploaded image, the id field only contains a UUID, and I don’t know how to build the image URL from that.

Can anyone help?

Hi!
You’ll need to fetch the image from the Atlassian media service using the uuid. You can use either MediaImage or MediaCard to display the media image.

1 Like

Hi @LuluWang, thanks for your reply.
I can’t reach your links, but found MediaImage.

For a MediaImage, I need a MediaClient, and to create that, I need an authProvider (and maybe an initialAuth). How do I get that provider? Could you show working example code?

Hi @LuluWang, did you see my reply?
It would be really useful to be able to use the blog post cover picture in our app.

(Sorry, did not get your question)

Hi
UUID of your uploaded image is fileId of the attachment
You can find it by fileId property
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-attachment/#api-blogposts-id-attachments-get