Skip to content

Commit 86198bb

Browse files
Internal Updates. (firebase#1422)
* Add logic to trim webp parameter from native image urls
1 parent 669b0fb commit 86198bb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gma/src/android/native_ad_image_android.cc

+9
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ NativeAdImage::NativeAdImage(
7171
FIREBASE_ASSERT(j_uri);
7272
internal_->uri = util::JniUriToString(env, j_uri);
7373

74+
// Images requested with an android user agent may return webp images. Trim
75+
// webp parameter from image url to get the original JPG/PNG image.
76+
std::size_t eq_pos = internal_->uri.rfind("=");
77+
std::size_t webp_pos = internal_->uri.rfind("-rw");
78+
if (webp_pos != std::string::npos && eq_pos != std::string::npos &&
79+
webp_pos > eq_pos) {
80+
internal_->uri.replace(webp_pos, 3, "");
81+
}
82+
7483
// NativeAdImage scale.
7584
jdouble j_scale =
7685
env->CallDoubleMethod(internal_->native_ad_image,

0 commit comments

Comments
 (0)