From a59700683122336599f840d930f0d369e14d1bbd Mon Sep 17 00:00:00 2001
From: Cameron <e107inc@gmail.com>
Date: Thu, 16 May 2019 10:50:18 -0700
Subject: [PATCH] Issue #3721 Avatar crop support added. Simple usage:
 {USER_AVATAR: w=150&h=150&crop=1&shape=circle}

---
 e107_handlers/e_parse_class.php | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index 13c32ef81..880cdfc2b 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -4269,13 +4269,14 @@ class e_parser
 	/**
 	 * Render an avatar based on supplied user data or current user when missing. 
 	 * @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())
 	{
 		$tp 		= e107::getParser();
 		$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  = '';
 		$linkEnd    =  '';
 
@@ -4310,11 +4311,11 @@ class e_parser
 			{
 				
 				$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
 			{
-				$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. 
 			{