This code is probably pretty messy, but whatever. This fixes the number of images in a thead correctly.
The current one doesn't count the images OP posted when he started the thread.
It also doesn't take into account multi-image posting.
I don't know how to get it working in the catalog. It displays the number of images in the replies correctly, but doesn't count images in the beginning of the thread.
I have no idea why it's even displaying the reply numbers correctly in the first place, so I'm pretty confused…/*correctly displays the image count*/
$('document').ready( function () {
var threadNum = (document.location.pathname + document.location.search).split('/');
threadNum = threadNum[threadNum.length -1].split('+')[0].split('.')[0];
var replies = $('#thread_'+ threadNum +' > div.post.reply:not(.post-hover):not(.inline)');
//images in OP
var threadStart = $('#thread_'+ threadNum +' > div.files');
var threadFiles = threadStart.find(' > .file');
var first = threadFiles.length;
//images in replies
//finds all replies with images.
var imgReplies = replies.filter(function(){
return $(this).find('> .files').text().trim() != false;
});
//gets the number of images in each reply
var imgCounts = imgReplies.map( function () {
var files = $(this).find('> .files');
//console.log(files);
return files.find(' > .file').length;
});
//sums up the number of images.
/*will use reduce function later for cleaner code*/
var count = 0;
for(var i = 0; i < imgCounts.length; i++){
count += imgCounts[i];
}
//adds number of images from replies and first post together.
$('#thread_stats_images').text(count + first);
});