Reddit Style picture thumbnail on the left

I was asked a question about this here, so just making a few notes here as this feature seems to have a fair amount of interest.

  1. As @lightyear pointed out here, the server creates this attribute by pulling the image from the first post (his link is a out of date now, the relevant code is here). The way you would change which image is used in the preview is also provided by @lightyear in the same topic here. i.e. you override the update_topic_image method in the CookedPostProcessor.

  2. As @rewphus points out in his nifty solution, if you override a template you’re prone to issues with changes to that template in Discourse core in the future.

  3. The way to achieve this, or adding anything else to topic list items, in a plugin without overriding topic-list-item.raw.hbs is by using the topic-list-tags plugin outlet in the topic-list-item.raw.hbs template and adding a handlebars helper that gives you the raw html to insert. The model for this approach is the tagging plugin. See here. I’ve published an example plugin for this approach here which adds the topic.image_url to each topic list item.

Note that the topic list item properties are available in your new connected view through the context object. See further here.

3 Likes