/** * Find user avatar * Will be used for sharding * @param integer $userId * @param string $userName * @param string $avatarPath * @param string $size - optional size tag */ public static function findAvatar($userId, $userName, $avatarPath, $size = 'thumb') { if (!strlen($avatarPath)) { return '/media/user/avatar/unknown_user.png'; } return Model_Medialib::getImgPath($avatarPath, '.jpg', $size); }
/** * Get item info for mediaitem field */ public function infoAction() { $id = Request::post('id', 'integer', false); if (!$id) { Response::jsonSuccess(array('exists' => false)); } $item = Model::factory('Medialib')->getItem($id); if (empty($item)) { Response::jsonSuccess(array('exists' => false)); } if ($item['type'] == 'image') { $icon = Model_Medialib::getImgPath($item['path'], $item['ext'], 'thumbnail', true) . '?m=' . date('ymdhis', strtotime($item['modified'])); } else { $icon = $this->_configMain->get('wwwroot') . 'i/unknown.png'; } Response::jsonSuccess(array('exists' => true, 'type' => $item['type'], 'icon' => $icon, 'title' => $item['title'], 'size' => Utils::formatFileSize($item['size']))); }