[go: nahoru, domu]

Skip to content

Commit

Permalink
Photo viewer now uses low quality for the lo-res image
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Jan 24, 2015
1 parent 2eb9839 commit 6186933
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public static String fixAvatar(final String imageUrl, int avatarSz) {
return "";

// if this isn't a gravatar image, return as resized photon image url
if (!imageUrl.contains("gravatar.com"))
if (!imageUrl.contains("gravatar.com")) {
return getPhotonImageUrl(imageUrl, avatarSz, avatarSz);
}

// remove all other params, then add query string for size and "mystery man" default
return UrlUtils.removeQuery(imageUrl) + "?s=" + avatarSz + "&d=mm";
Expand All @@ -35,12 +36,13 @@ public static boolean isMshotsUrl(final String imageUrl) {
}

/*
* returns a photon url for the passed image with the resize query set to the passed dimensions
* returns a photon url for the passed image with the resize query set to the passed
* dimensions - note that the passed quality parameter will only affect JPEGs
*/
public static enum Quality {
HIGH,
MEDIUM,
LOW,
LOW
}
public static String getPhotonImageUrl(String imageUrl, int width, int height) {
return getPhotonImageUrl(imageUrl, width, height, Quality.MEDIUM);
Expand Down Expand Up @@ -85,7 +87,7 @@ public static String getPhotonImageUrl(String imageUrl, int width, int height, Q
}

// if both width & height are passed use the "resize" param, use only "w" or "h" if just
// one of them is set - note that the passed quality parameter will only affect JPEGs
// one of them is set
final String query;
if (width > 0 && height > 0) {
query = "?resize=" + width + "," + height + "&" + qualityParam;
Expand Down

0 comments on commit 6186933

Please sign in to comment.