Skip to content

Commit 17b8903

Browse files
fix: resolve image rendering issue in Online Synchronization mode on Android
1 parent 66b319e commit 17b8903

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

packages/pluggableWidgets/image-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue that caused images from entities to not render on Android in Online Synchronization mode
12+
913
## [3.1.1] - 2026-6-10
1014

1115
### Changed

packages/pluggableWidgets/image-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "image-native",
33
"widgetName": "Image",
4-
"version": "3.1.1",
4+
"version": "3.1.2",
55
"description": "Display an image and enlarge it on click",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
77
"license": "Apache-2.0",

packages/pluggableWidgets/image-native/src/components/ImageIconSVG.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FunctionComponent, Fragment, useCallback } from "react";
2-
import { View } from "react-native";
2+
import { ImageURISource, Platform, View } from "react-native";
33
import { SvgUri, SvgXml } from "react-native-svg";
44
import FastImageComponent, { Source } from "@d11/react-native-fast-image";
55
import { extractStyles } from "@mendix/pluggable-widgets-tools";
@@ -64,11 +64,19 @@ export const ImageIconSVG: FunctionComponent<ImageIconSVGProps> = props => {
6464
);
6565

6666
if (image && (type === "staticImage" || type === "dynamicImage")) {
67+
// FastImage's Glide/OkHttp client on Android can be initialized before the app wires up
68+
// its cookie-decrypting network interceptor, causing remote (online document) images to
69+
// fail to load with 401s. RN's own Image component always picks up the interceptor, so
70+
// fall back to it for remote urls on Android.
71+
const uri = typeof image === "object" ? (image as ImageURISource)?.uri : undefined;
72+
const useFallback = Platform.OS === "android" && typeof uri === "string" && /^https?:\/\//i.test(uri);
73+
6774
return (
6875
<FastImageComponent
6976
testID={`${name}$Image`} // Broken because of https://github.com/DylanVann/react-native-fast-image/issues/221
7077
source={image as Source | number}
7178
resizeMode={resizeMode || "contain"}
79+
fallback={useFallback}
7280
style={[
7381
initialDimensions?.aspectRatio ? { aspectRatio: +initialDimensions.aspectRatio?.toFixed(2) } : {},
7482
width && height ? { width, height } : {},

packages/pluggableWidgets/image-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="Image" version="3.1.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Image" version="3.1.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="Image.xml" />
66
</widgetFiles>

packages/pluggableWidgets/image-native/src/utils/imageUtils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ function getBundledAssetSource(value: NativeImage | Readonly<ImageURISource | st
3131
return undefined;
3232
}
3333

34+
function toAndroidUri(uri: string): string {
35+
// Online images are served by the Mendix runtime as http(s) URLs and must be requested as
36+
// such so cookies are attached; only local file paths need the file:/// scheme prepended.
37+
return Platform.OS === "android" && !/^https?:\/\//i.test(uri) ? `file:///${uri}` : uri;
38+
}
39+
3440
export async function convertImageProps(
3541
datasource: DatasourceEnum,
3642
imageIcon: DynamicValue<NativeIcon> | undefined,
@@ -74,14 +80,14 @@ export async function convertImageProps(
7480
} else if (typeof imageValue === "object" && imageValue?.uri && imageValue?.name?.endsWith(".svg")) {
7581
return {
7682
type: "dynamicSVG", // Dynamic image SVG
77-
image: (Platform.OS === "android" ? "file:///" : "") + imageValue.uri
83+
image: toAndroidUri(imageValue.uri as string)
7884
};
7985
} else if (typeof imageValue === "object" && imageValue?.uri) {
8086
return {
8187
type: "dynamicImage", // Dynamic image
8288
image: {
8389
...imageValue,
84-
uri: (Platform.OS === "android" ? "file:///" : "") + imageValue.uri
90+
uri: toAndroidUri(imageValue.uri as string)
8591
}
8692
};
8793
}

0 commit comments

Comments
 (0)