Skip to content

Commit

Permalink
More avatar updates, fewer repetitive calls
Browse files Browse the repository at this point in the history
  • Loading branch information
nul800sebastiaan committed Mar 31, 2021
1 parent e977c17 commit 326292c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion OurUmbraco/Community/People/AvatarService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ internal static string GetCleanImagePath(string imgPath)
{
if (imgPath == null)
return string.Empty;


var siteDirectory = HostingEnvironment.MapPath("~");
if (imgPath.StartsWith(siteDirectory))
imgPath = imgPath.Replace(siteDirectory, string.Empty).Replace("\\", "/");

var cleanImagePath = imgPath.Replace(" ", "%20").TrimStart("~");
if (cleanImagePath.Contains("?"))
cleanImagePath = cleanImagePath.Substring(0, cleanImagePath.IndexOf("?", StringComparison.Ordinal));
Expand Down
1 change: 0 additions & 1 deletion OurUmbraco/Our/Models/MemberData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class MemberData
public int NumberOfForumPosts { get; set; }
public string AvatarHtml { get; set; }
public string AvatarPath { get; set; }
public Image AvatarImage { get; set; }
public bool AvatarImageTooSmall { get; set; }
public bool IsBlocked { get; set; }
public bool NewTosAccepted { get; set; }
Expand Down
6 changes: 2 additions & 4 deletions OurUmbraco/Our/Models/OurUmbracoTemplatePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,16 @@ private static MemberData GetMemberData()
if ((newTosDate - tosAccepted).TotalDays > 1)
newTosAccepted = false;

var avatarPath = avatarService.GetMemberAvatar(member);
var avatarHtml = avatarService.GetImgWithSrcSet(avatarPath, member.Name, 100);
var avatarHtml = avatarService.GetImgWithSrcSet(memberAvatarPath, member.Name, 100);

var data = new MemberData
{
Member = member,
AvatarImage = avatarImage,
AvatarImageTooSmall = avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400),
Roles = roles,
LatestTopics = latestTopics,
AvatarHtml = avatarHtml,
AvatarPath = avatarPath,
AvatarPath = memberAvatarPath,
NumberOfForumPosts = member.ForumPosts(),
Karma = member.Karma(),
TwitterHandle = member.GetPropertyValue<string>("twitter").Replace("@", string.Empty),
Expand Down

0 comments on commit 326292c

Please sign in to comment.