Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gma/src/android/native_ad_image_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ NativeAdImage::NativeAdImage(
FIREBASE_ASSERT(j_uri);
internal_->uri = util::JniUriToString(env, j_uri);

// Images requested with an android user agent may return webp images. Trim
// webp parameter from image url to get the original JPG/PNG image.
std::size_t eq_pos = internal_->uri.rfind("=");
std::size_t webp_pos = internal_->uri.rfind("-rw");
if (webp_pos != std::string::npos && eq_pos != std::string::npos &&
webp_pos > eq_pos) {
internal_->uri.replace(webp_pos, 3, "");
}

// NativeAdImage scale.
jdouble j_scale =
env->CallDoubleMethod(internal_->native_ad_image,
Expand Down