Single topic API endpoint should contain `image_url`

When you fetch a list of all topics with a certain tag (e.g. https://meta.discourse.org/tags/ui.json), each topic contains an image_url field. If you fetch, however, only one topic (e.g. https://meta.discourse.org/t/37245.json) it does not contain an image_url field. This is kind of inconsistent and it would help me a lot if it was available. Can you maybe add it?

My workaround for the time being is:

response.image_url = (response.post_stream.posts[0].cooked
  .match(/src=\"(.+?)\"/) || [])[1]
3 Likes

I’ve just come across this post looking for the same thing.

Does anyone know if there’s a way of adding this (e.g. with a plugin)?

1 Like

I created a commit that adds the image_url to the topic serializer:

4 Likes

Brilliant! Thanks @blake! :+1:

1 Like