diff --git a/src/main/java/com/erudika/scoold/utils/HttpUtils.java b/src/main/java/com/erudika/scoold/utils/HttpUtils.java
index 14099b3e..54aa5899 100644
--- a/src/main/java/com/erudika/scoold/utils/HttpUtils.java
+++ b/src/main/java/com/erudika/scoold/utils/HttpUtils.java
@@ -196,6 +196,12 @@ public static String getCookieValue(HttpServletRequest req, String name) {
/**
* Fetches an avatar at a given URL.
+ *
+ * /////////////////////////////////////
+ * THIS CODE IS CAUSING MORE PROBLEMS
+ * THAN IT SOLVES! CONSIDER DELETING!!!
+ * ////////////////////////////////////
+ *
* @param url image URL
* @param req request
* @param res response
@@ -206,6 +212,9 @@ public static void getAvatar(String url, HttpServletRequest req, HttpServletResp
getDefaultAvatarImage(res);
return;
}
+ if (!ScooldUtils.getInstance().isAvatarValidationEnabled()) {
+ return;
+ }
HttpGet get = new HttpGet(url);
// attach auth cookie to requests for locally uploaded avatars - without this custom avatars will not be loaded!
if (StringUtils.startsWithIgnoreCase(url, ScooldServer.getServerURL())) {
diff --git a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
index 04a0a0b8..f963cab6 100755
--- a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
+++ b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
@@ -745,6 +745,10 @@ public boolean isDarkModeEnabled() {
return Config.getConfigBoolean("dark_mode_enabled", true);
}
+ public boolean isAvatarValidationEnabled() {
+ return Config.getConfigBoolean("avatar_validation_enabled", false); // this should be deleted in the future
+ }
+
public String getFooterHTML() {
return Config.getConfigParam("footer_html", "");
}
@@ -1328,6 +1332,14 @@ public static String getGravatar(Profile profile) {
}
}
+ public String getFullAvatarURL(Profile profile) {
+ if (profile == null) {
+ return getGravatar("");
+ }
+ return isAvatarValidationEnabled() ? PEOPLELINK + "/avatar?url=" + Utils.urlEncode(profile.getPicture()) :
+ profile.getPicture();
+ }
+
public void clearSession(HttpServletRequest req, HttpServletResponse res) {
if (req != null) {
HttpUtils.removeStateParam(AUTH_COOKIE, req, res);
diff --git a/src/main/resources/checkstyle.xml b/src/main/resources/checkstyle.xml
index b1fe751d..6bb6ae88 100644
--- a/src/main/resources/checkstyle.xml
+++ b/src/main/resources/checkstyle.xml
@@ -10,7 +10,9 @@
-
+
+
+
diff --git a/src/main/resources/static/styles/style.css b/src/main/resources/static/styles/style.css
index 5912245e..b568c760 100755
--- a/src/main/resources/static/styles/style.css
+++ b/src/main/resources/static/styles/style.css
@@ -347,6 +347,19 @@ img.profile-pic {
.user-card img.profile-pic {
width: 100%;
}
+img.profile-pic:before {
+ content: " ";
+ display: block;
+ position: absolute;
+ box-sizing: border-box;
+ background-image: url('/people/avatar');
+ background-clip: initial;
+ background-attachment: initial;
+ background-position: initial;
+ background-size: cover;
+ height: calc(100% - 11%);
+ width: calc(100% - 71%);
+}
.card .card-website a:not(.btn):not(.btn-large):not(.btn-small):not(.btn-large):not(.btn-floating) {
margin-right: 0;
text-transform: lowercase;
@@ -523,6 +536,10 @@ img.profile-pic {
.approve-answer-btn {
padding: 0 10px;
}
+ img.profile-pic:before {
+ height: calc(100% - 14%);
+ width: calc(100% - 79%);
+ }
}
/**** FEEL FREE TO MODIFY THIS THEME ****/
diff --git a/src/main/resources/templates/macro.vm b/src/main/resources/templates/macro.vm
index 5b50a517..b53efffe 100755
--- a/src/main/resources/templates/macro.vm
+++ b/src/main/resources/templates/macro.vm
@@ -988,7 +988,7 @@ $utils.formatDate($date, $format, $currentLocale)
#end
#####################################
-#macro(profilepic $user)#if($user && $user.picture && $user.picture.matches("^(http:|https:).*"))$peoplelink/avatar?url=$utils.urlEncode($!user.picture)#elseif($user && $user.picture && $user.picture.matches("^(data:).*"))$user.picture #else $!imageslink/anon.svg #end#end
+#macro(profilepic $user)#if($user && $user.picture && $user.picture.matches("^(http:|https:).*"))$scooldUtils.getFullAvatarURL($user)#elseif($user && $user.picture && $user.picture.matches("^(data:).*"))$user.picture #else $!imageslink/anon.svg #end#end
#####################################
#macro(infostrip )
#if ($request.getParameter("success"))