Then you could alter the code above to:
% /* Put this in theme.php, inside the `theme_custom` function. */ foreach ($template->query('.nnf_reply-author, #nnf_post-author') as $node) { // The file we want, md5 of the user name and the PNG extension: $filename = md5(trim($node->nodeValue)) . '.png'; // The avatar directory on the server, I am assuming in the forum root: $avatardir = FORUM_ROOT . DIRECTORY_SEPARATOR . 'avatar' . DIRECTORY_SEPARATOR; // Test if the file exists in the directory: if (!file_exists ($avatardir . $filename)) { $filename = 'default.png'; } // Write the HTML for the avatar: $value = '<img src="/avatar/' . $filename . '" alt="" /> ' . $node->nodeValue; $node->nodeValue = ''; $frag = $node->ownerDocument->createDocumentFragment(); if (!@$frag->appendXML($value) || !@$node->appendChild($frag)) { throw new Exception("Invalid HTML"); } } %
I didn't change much except the layout of the code. As with previous version, it still checks for the avatar of the user, but now falls back to the default one. The default avatar is named `default.png`, and should be in the avatar directory.