Last Poster Avatar Variable in Forum Row (& Topic Row!)

Aug 31 2020, 03:05 PM

<!-- |last_poster_avatar| --> <!-- |last_poster_avatar_url| --> variables are now available in Forum Row & Topic Row templates.

This is a small update, but we're making it an announcement because so many are already using a work-around to get this feature.

A common implementation of this is usually the following, is an old method:

CODE
/* DON'T USE THIS METHOD ANYMORE! */

background-image: url('path//av-<!-- |last_poster_id| -->.png'), url('path/av-av-<!-- |last_poster_id| -->.gif'), url('path//av-<!-- |last_poster_id| -->.jpg'), url('path/av-<!-- |last_poster_id| -->.jpeg'), url('default');

While this method works, it has two major downsides:

1. It has to try multiple image requests until it reaches the correct one! It can take up to 3 tries to get the working avatar URL. This wastes browser requests and resources.

2. You cannot allow URL avatars, uploaded avatars are required. they won't work. Free and premium service, while allowing generous space, have limitations and this is also not as convenient for users who may wish to link the same URL across many sites.

The variable(s) addresses both issues so you can simply use the following and keep URL avatars enabled! with the new method:

CODE
background-image: url('<!-- |last_poster_avatar_url| -->');

And that's it. There are no upload folder paths to consider, no site names or links, the CSS is condensed...the variable handles it all for you.

If you want need to set a default avatar for the url variable, a new macro has also been created called <{AVATAR_URL}> or you are welcome to put the default avatar url at the end as a second request since it defaults to a null url, like this:

CODE
background-image: url('<!-- |last_poster_avatar_url| -->'), url('default avatar url');

Let us know if you experience any problems using this new feature!

Best regards,

John & the JFH Team