Change Default Avatar in home page (for original author avatar)


(Mario Carvajal) #1

How I can change the default avatar in the list of recent post in home page? I need to show the avatar of the original author of post, not the last participant, because if I respond at last, all avatars are my ugly face…


(Jeff Atwood) #2

That’s the way it works. If avatars are always the first poster they get very monotonous over time, since the first poster never changes.


#3

But is there a way to do it?

Best regards,
Neso


(David Kingham) #4

I would like to dredge this back up. For our particular needs I would much prefer to show the original post author on latest rather than the last reply author. Is it even possible or is this so embedded in core that it couldn’t be done with a plugin?


(Joe) #5

If you’re referring to the “latest” list on the categories page, then this is what you need to change:

If you want the avatar of the topic creator, you need to pass that instead, so you go from

{{#user-link user=topic.lastPoster}}
  {{avatar topic.lastPoster imageSize="large"}}
{{/user-link}}

to

{{#user-link user=topic.creator}}
  {{avatar topic.creator imageSize="large"}}
{{/user-link}}

So something like this in the header section of your theme

<script type="text/x-handlebars" data-template-name="components/latest-topic-list-item">
<div class='topic-poster'>
 {{#user-link user=topic.creator}}
  {{avatar topic.creator imageSize="large"}}
 {{/user-link}}
</div>
<div class='main-link'>
 <div class='top-row'>
  {{raw "topic-status" topic=topic}}
  {{topic-link topic}}
  {{#if topic.featured_link}}
   {{topic-featured-link topic}}
  {{/if}}
  {{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}}
 </div>
 <div class='bottom-row'>
  {{category-link topic.category}}
  {{discourse-tags topic mode="list"}}
 </div>
</div>
<div class='topic-stats'>
 {{raw "list/posts-count-column" topic=topic tagName="div"}}
 <div class="topic-last-activity">
  <a href="{{topic.lastPostUrl}}" title="{{topic.bumpedAtTitle}}">{{format-date topic.bumpedAt format="tiny" noTitle="true"}}</a>
 </div>
</div>
</script>

there’s more on template overrides here


(David Kingham) #6

This works absolutely brilliantly, thank you Joe!


(Joe) #7