mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Issue #3721 Avatar crop support added. Simple usage: {USER_AVATAR: w=150&h=150&crop=1&shape=circle}
This commit is contained in:
@@ -4269,13 +4269,14 @@ class e_parser
|
|||||||
/**
|
/**
|
||||||
* Render an avatar based on supplied user data or current user when missing.
|
* Render an avatar based on supplied user data or current user when missing.
|
||||||
* @param @array - user data from e107_user.
|
* @param @array - user data from e107_user.
|
||||||
* @return <img> tag of avatar.
|
* @return string <img> tag of avatar.
|
||||||
*/
|
*/
|
||||||
public function toAvatar($userData=null, $options=array())
|
public function toAvatar($userData=null, $options=array())
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$width = !empty($options['w']) ? intval($options['w']) : $tp->thumbWidth;
|
$width = !empty($options['w']) ? intval($options['w']) : $tp->thumbWidth;
|
||||||
$height = ($tp->thumbHeight !== 0) ? $tp->thumbHeight : "";
|
$height = ($tp->thumbHeight !== 0) ? $tp->thumbHeight : "";
|
||||||
|
$crop = !empty($options['crop']) ? $options['crop'] : $tp->thumbCrop;
|
||||||
$linkStart = '';
|
$linkStart = '';
|
||||||
$linkEnd = '';
|
$linkEnd = '';
|
||||||
|
|
||||||
@@ -4310,11 +4311,11 @@ class e_parser
|
|||||||
{
|
{
|
||||||
|
|
||||||
$image = substr($image,8); // strip the -upload- from the beginning.
|
$image = substr($image,8); // strip the -upload- from the beginning.
|
||||||
$img = (file_exists(e_AVATAR_UPLOAD.$image)) ? $tp->thumbUrl(e_AVATAR_UPLOAD.$image,"w=".$width."&h=".$height) : $genericImg;
|
$img = (file_exists(e_AVATAR_UPLOAD.$image)) ? $tp->thumbUrl(e_AVATAR_UPLOAD.$image,"w=".$width."&h=".$height."&crop=".$crop) : $genericImg;
|
||||||
}
|
}
|
||||||
elseif(file_exists(e_AVATAR_DEFAULT.$image)) // User-Uplaoded Image
|
elseif(file_exists(e_AVATAR_DEFAULT.$image)) // User-Uplaoded Image
|
||||||
{
|
{
|
||||||
$img = $tp->thumbUrl(e_AVATAR_DEFAULT.$image,"w=".$width."&h=".$height);
|
$img = $tp->thumbUrl(e_AVATAR_DEFAULT.$image,"w=".$width."&h=".$height."&crop=".$crop);
|
||||||
}
|
}
|
||||||
else // Image Missing.
|
else // Image Missing.
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user