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:

https://github.com/discourse/discourse/commit/3201613f138bf574577d77631f8214098e22b7e3

5 Likes

Brilliant! Thanks @blake! :+1:

1 Like

Can i use: /search.json?q=loreal&image_url=true

I want to display image_url in the json results I return when searching for the topic