Skip to content

Commit a2ce056

Browse files
committed
Added default quality param to photon
1 parent 5a48a06 commit a2ce056

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/PhotonUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static boolean isMshotsUrl(final String imageUrl) {
3737
/*
3838
* returns a photon url for the passed image with the resize query set to the passed dimensions
3939
*/
40+
private static final String QUALITY_PARAM = "quality=65";
4041
public static String getPhotonImageUrl(String imageUrl, int width, int height) {
4142
if (TextUtils.isEmpty(imageUrl)) {
4243
return "";
@@ -68,16 +69,16 @@ public static String getPhotonImageUrl(String imageUrl, int width, int height) {
6869
}
6970

7071
// if both width & height are passed use the "resize" param, use only "w" or "h" if just
71-
// one of them is set, otherwise no query string
72+
// one of them is set - note that the passed quality parameter will only affect JPEGs
7273
final String query;
7374
if (width > 0 && height > 0) {
74-
query = "?resize=" + width + "," + height;
75+
query = "?resize=" + width + "," + height + "&" + QUALITY_PARAM;
7576
} else if (width > 0) {
76-
query = "?w=" + width;
77+
query = "?w=" + width + "&" + QUALITY_PARAM;
7778
} else if (height > 0) {
78-
query = "?h=" + height;
79+
query = "?h=" + height + "&" + QUALITY_PARAM;
7980
} else {
80-
query = "";
81+
query = "?" + QUALITY_PARAM;
8182
}
8283

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

0 commit comments

Comments
 (0)