Camen Design Forum

Delete

(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE[33]: embedd youtube videos?

Nikolai

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.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn