public function getAvatar($size = 32) { if ($this->user_id) { $cache = new YCache(ZOO_CACHE_PATH . DS . 'author_cache.txt', true, 604800); $cache_check = $cache ? $cache->check() : false; $url = ''; // try to get avatar url from cache if ($cache_check) { $url = $cache->get($this->user_id); } // if url is empty, try to get avatar url from twitter if (empty($url)) { $info = CommentHelper::getTwitterFields($this->user_id, array('profile_image_url')); if (isset($info['profile_image_url'])) { $url = $info['profile_image_url']; } if ($cache_check) { $cache->set($this->user_id, $url); $cache->save(); } } if (!empty($url)) { return '<img alt="' . $this->name . '" title="' . $this->name . '" src="' . $url . '" height="' . $size . '" width="' . $size . '" />'; } } return parent::getAvatar($size); }