Android and iOS apps

Mobile App Integration

Optimised 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 resized version of your image. This function will identify the correct dimension 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)"
}