Skip to content

Commit

Permalink
Internal Updates. (#1422)
Browse files Browse the repository at this point in the history
* Add logic to trim webp parameter from native image urls
  • Loading branch information
nakirekommula authored Aug 10, 2023
1 parent 669b0fb commit 86198bb
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 86198bb

Please sign in to comment.