diff --git a/include/class.thread.php b/include/class.thread.php
index bf4d4010ef3c2fcb5428ac03a834efc39481e9e4..0636df348a0d3a990a5778f1793ef80f165e762b 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -1567,9 +1567,9 @@ class ThreadEvent extends VerySimpleModel {
 
     function getAvatar($size=null) {
         if ($this->uid && $this->uid_type == 'S')
-            return $this->agent->getAvatar($size);
+            return $this->agent ? $this->agent->getAvatar($size) : '';
         if ($this->uid && $this->uid_type == 'U')
-            return $this->user->getAvatar($size);
+            return $this->user ? $this->user->getAvatar($size) : '';
     }
 
     function getUserName() {