本文整理汇总了PHP中UserUtil::getAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::getAvatar方法的具体用法?PHP UserUtil::getAvatar怎么用?PHP UserUtil::getAvatar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserUtil
的用法示例。
在下文中一共展示了UserUtil::getAvatar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCropImg
public function actionCropImg()
{
if (EnvUtil::submitCheck("userSubmit")) {
$params = $_POST;
if (!isset($params) && empty($params)) {
return null;
}
$tempAvatar = $params["src"];
$avatarPath = "data/avatar/";
$avatarBig = UserUtil::getAvatar($params["uid"], "big");
$avatarMiddle = UserUtil::getAvatar($params["uid"], "middle");
$avatarSmall = UserUtil::getAvatar($params["uid"], "small");
if (LOCAL) {
FileUtil::makeDirs($avatarPath . dirname($avatarBig));
}
FileUtil::createFile("data/avatar/" . $avatarBig, "");
FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
FileUtil::createFile("data/avatar/" . $avatarSmall, "");
Ibos::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
$imgObj->open($tempAvatar)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($tempAvatar);
$imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
$imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
$imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
$this->success(Ibos::lang("Upload avatar succeed"), $this->createUrl("home/personal", array("op" => "avatar")));
exit;
}
}
示例2: checkAvatar
protected function checkAvatar($users)
{
$avatar = UserUtil::getAvatar($users["uid"]);
if (FileUtil::fileExists("data/avatar/" . $avatar)) {
return true;
} else {
return false;
}
}
示例3: actionUpload
public function actionUpload()
{
if ($_FILES["avatar"]) {
$upload = FileUtil::getUpload($_FILES["avatar"]);
if (!$upload->save()) {
echo "出错了";
} else {
$info = $upload->getAttach();
$file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
$fileUrl = FileUtil::fileName($file);
$uid = Yii::app()->user->uid;
$tempAvatar = $file;
$avatarPath = "data/avatar/";
$avatarBig = UserUtil::getAvatar($uid, "big");
$avatarMiddle = UserUtil::getAvatar($uid, "middle");
$avatarSmall = UserUtil::getAvatar($uid, "small");
if (LOCAL) {
FileUtil::makeDirs($avatarPath . dirname($avatarBig));
}
FileUtil::createFile("data/avatar/" . $avatarBig, "");
FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
FileUtil::createFile("data/avatar/" . $avatarSmall, "");
Yii::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
$imgTemp = $imgObj->open($tempAvatar);
$params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
if ($params["h"] < $params["w"]) {
$params["x"] = ($params["w"] - $params["h"]) / 2;
$params["w"] = $params["h"];
} else {
$params["y"] = ($params["h"] - $params["w"]) / 2;
$params["h"] = $params["w"];
}
$imgObj->open($tempAvatar)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($tempAvatar);
$imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
$imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
$imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
}
}
}
示例4: cropImg
private function cropImg()
{
$uid = Ibos::app()->user->uid;
$tempAvatar = $_POST["src"];
$avatarPath = "data/avatar/";
$avatarBig = UserUtil::getAvatar($uid, "big");
$avatarMiddle = UserUtil::getAvatar($uid, "middle");
$avatarSmall = UserUtil::getAvatar($uid, "small");
if (LOCAL) {
FileUtil::makeDirs($avatarPath . dirname($avatarBig));
}
FileUtil::createFile("data/avatar/" . $avatarBig, "");
FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
FileUtil::createFile("data/avatar/" . $avatarSmall, "");
Ibos::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
$imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
$imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
$imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
}