The discussion revolves around including images in topic excerpts when using Discourse as a headless API server. chandan.gupta wants to display full topic text, including images, in their custom-built landing page and suggests adding site settings (post_excerpt_markdown_images, post_excerpt_strip_images, and post_excerpt_strip_links) to achieve this.
However, awesomerobot points out that the full cooked content, which includes images, can be retrieved directly. chandan.gupta clarifies that they need the full topic text when hitting /latest.json, which only returns the topic title by default.
chandan.gupta creates a draft PR to get early feedback, but Johani suggests creating a plugin instead, as adding extra site settings is not preferred unless there is high demand. chandan.gupta agrees and considers creating a plugin.
sam cautions that creating a plugin might have unintended results, but chandan.gupta proposes an alternative solution: returning posts[0].raw or posts[0].cooked along with /latest.json, which would satisfy their needs without modifying the excerpt.
I am trying to set up Discourse as a headless API server. I need to show the full text of the topic and the images in my custom-built landing page. I am able to get the full text with always_include_topic_excerpts setting. However, the excerpt doesn’t have images.
Hi Kris, thanks for responding. I need the full topic text when I hit /latest.json. By default, it only returns the topic title with the exception of some posts (announcements?) where it also returns an excerpt. With the always_include_topic_excerts setting on, I am able to get the full text except links and images. I am looking for a way to get links and images in the excerpt.
Thanks for the draft PR @chandan.gupta but we strip images from excerpts for a reason
and we also don’t like to add extra site settings unless there’s a lot of demand for them. If you really need this on your site, then I suggest creating a plugin for it.
@sam would it be a complex plugin to return the posts[0].raw or posts[0].cooked along with /latest.json? This way, we wouldn’t need to piggyback on “excerpt”, and it would also satisfy our needs. Could you point me to any reference to implement this? I understand that this would involve a lot more database reads, but I am ok with this performance cost.