Skip to content

Commit

Permalink
Added default quality param to photon
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Jan 24, 2015
1 parent 728a121 commit 5ae1b87
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static boolean isMshotsUrl(final String imageUrl) {
/*
* returns a photon url for the passed image with the resize query set to the passed dimensions
*/
private static final String QUALITY_PARAM = "quality=65";
public static String getPhotonImageUrl(String imageUrl, int width, int height) {
if (TextUtils.isEmpty(imageUrl)) {
return "";
Expand Down Expand Up @@ -68,16 +69,16 @@ public static String getPhotonImageUrl(String imageUrl, int width, int height) {
}

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

// return passed url+query if it's already a photon url
Expand Down

0 comments on commit 5ae1b87

Please sign in to comment.