Android and iOS apps
Mobile App Integration
Optimized images can be served via Gumlet using your existing infrastructure with minimal code changes. Here are template code requirements for Android and iOS applications.
Use this buildImageUrl()
function to get the image URL of the resized version of your image. This function will identify the correct dimensions for your image and modify the image URL accordingly.
Android
Url buildImageUrl(View view, String baseImageUrl) {
int imageWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
return baseImageUrl + "?w=" + Math.round(imageWidth);
}
iOS
public func buildImageUrl(view: UIImageView, baseImageUrl: String) -> String {
let imageWidth = round(view.frame.width - view.layoutMargins.left - view.layoutMargins.right)
return baseImageUrl + "?w=" + "\(imageWidth)"
}
Updated 7 months ago