File tree Expand file tree Collapse file tree 2 files changed +20
-18
lines changed
WordPressUtils/src/main/java/org/wordpress/android/util Expand file tree Collapse file tree 2 files changed +20
-18
lines changed Original file line number Diff line number Diff line change 11package org .wordpress .android .util ;
22
3- public class GravatarUtils {
3+ import android . text . TextUtils ;
44
5+ public class GravatarUtils {
56 /*
67 * see https://en.gravatar.com/site/implement/images/
78 */
@@ -36,6 +37,24 @@ public String toString() {
3637 }
3738 }
3839
40+ /*
41+ * gravatars often contain the ?s= parameter which determines their size - detect this and
42+ * replace it with a new ?s= parameter which requests the avatar at the exact size needed
43+ */
44+ public static String fixGravatarUrl (final String imageUrl , int avatarSz ) {
45+ if (TextUtils .isEmpty (imageUrl )) {
46+ return "" ;
47+ }
48+
49+ // if this isn't a gravatar image, return as resized photon image url
50+ if (!imageUrl .contains ("gravatar.com" )) {
51+ return PhotonUtils .getPhotonImageUrl (imageUrl , avatarSz , avatarSz );
52+ }
53+
54+ // remove all other params, then add query string for size and "mystery man" default
55+ return UrlUtils .removeQuery (imageUrl ) + "?s=" + avatarSz + "&d=mm" ;
56+ }
57+
3958 public static String gravatarFromEmail (final String email , int size ) {
4059 return gravatarFromEmail (email , size , DefaultImage .MYSTERY_MAN );
4160 }
Original file line number Diff line number Diff line change @@ -12,23 +12,6 @@ private PhotonUtils() {
1212 throw new AssertionError ();
1313 }
1414
15- /*
16- * gravatars often contain the ?s= parameter which determines their size - detect this and
17- * replace it with a new ?s= parameter which requests the avatar at the exact size needed
18- */
19- public static String fixAvatar (final String imageUrl , int avatarSz ) {
20- if (TextUtils .isEmpty (imageUrl ))
21- return "" ;
22-
23- // if this isn't a gravatar image, return as resized photon image url
24- if (!imageUrl .contains ("gravatar.com" )) {
25- return getPhotonImageUrl (imageUrl , avatarSz , avatarSz );
26- }
27-
28- // remove all other params, then add query string for size and "mystery man" default
29- return UrlUtils .removeQuery (imageUrl ) + "?s=" + avatarSz + "&d=mm" ;
30- }
31-
3215 /*
3316 * returns true if the passed url is an obvious "mshots" url
3417 */
You can’t perform that action at this time.
0 commit comments