本文整理匯總了PHP中Avatar::newSize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Avatar::newSize方法的具體用法?PHP Avatar::newSize怎麽用?PHP Avatar::newSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Avatar
的用法示例。
在下文中一共展示了Avatar::newSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: byProfile
public static function byProfile(Profile $target, $width = null, $height = null)
{
$width = intval($width);
$height = !is_null($height) ? intval($height) : null;
if (is_null($height)) {
$height = $width;
}
$size = "{$width}x{$height}";
if (!isset(self::$_avatars[$target->id])) {
self::$_avatars[$target->id] = array();
} elseif (isset(self::$_avatars[$target->id][$size])) {
return self::$_avatars[$target->id][$size];
}
$avatar = null;
if (Event::handle('StartProfileGetAvatar', array($target, $width, &$avatar))) {
$avatar = self::pkeyGet(array('profile_id' => $target->id, 'width' => $width, 'height' => $height));
Event::handle('EndProfileGetAvatar', array($target, $width, &$avatar));
}
if (is_null($avatar)) {
// Obviously we can't find an avatar, so let's resize the original!
$avatar = Avatar::newSize($target, $width);
} elseif (!$avatar instanceof Avatar) {
throw new NoAvatarException($target, $avatar);
}
self::$_avatars[$target->id]["{$avatar->width}x{$avatar->height}"] = $avatar;
return $avatar;
}