providers[] = $provider; return $this; } /** * Render avatar html element * * @access public * @param string $user_id * @param string $username * @param string $name * @param string $email * @param int $size * @return string */ public function render($user_id, $username, $name, $email, $size) { $user = array( 'id' => $user_id, 'username' => $username, 'name' => $name, 'email' => $email, ); krsort($this->providers); foreach ($this->providers as $provider) { if ($provider->isActive($user)) { return $provider->render($user, $size); } } return ''; } /** * Render default provider for unknown users (first provider registered) * * @access public * @param integer $size * @return string */ public function renderDefault($size) { if (count($this->providers) > 0) { ksort($this->providers); $provider = current($this->providers); $user = array( 'id' => 0, 'username' => '', 'name' => '?', 'email' => '', ); return $provider->render($user, $size); } return ''; } }