Is there a way to load images based on how many messages are in a thread view?


Well-known member
This is for a sidebar, I only want it to load 1 image by default, but if there's more than x posts loaded onto the page it should load a second image, and if more than y posts on a page it should load a 3rd image.

Any ideas?

Edit: Actually, ideally I'd like to check the height of all the messages, but that could perhaps vary if images are being loaded from an external source?

Jake Bunce

XenForo moderator
Staff member
Admin CP -> Appearance -> Templates -> thread_view

Add this code:

<xen:foreach loop="$posts" value="$post" count="$count">
Now you can reference {$count} anywhere after this code to check the number of posts on the page. Example:

<xen:if is="{$count} > 15">

<xen:elseif is="{$count} > 10" />

<xen:elseif is="{$count} > 5" />



Well-known member
Hmmm...I seem to get the following error on the thread after that:

Fatal error: Cannot use object of type XenForo_BbCode_TextWrapper as array in /home/domain/public_html/library/XenForo/Template/Abstract.php(265) : eval()'d code on line 663


Well-known member
I apologize - I've got it working perfectly now!

Thank you Jake, you're a gentleman and a scholar! :D