Skip to content

Commit 3b4f9c0

Browse files
authored
Visualise hero image from URL (#492)
1 parent 8bf0aa6 commit 3b4f9c0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

AndroidSDKCore/src/main/java/com/leanplum/messagetemplates/options/RichHtmlOptions.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private static String readFileAsString(ActionContext context, String name) {
120120

121121
/**
122122
* Replace all keys with __file__ prefix to keys without __file__ prefix and replace value of
123-
* those keys with local path to file.
123+
* those keys with local path to file. In case of URL it will leave the value unchanged.
124124
*
125125
* @param map Map with arguments from ActionContext.
126126
* @param htmlTemplateName Name of file with HTML template.
@@ -143,13 +143,18 @@ private static Map<String, Object> replaceFileToLocalPath(Map<String, Object> ma
143143
if (filePath == null) {
144144
continue;
145145
}
146-
File f = new File(filePath);
147-
String localPath = "file://" + f.getAbsolutePath();
148-
if (localPath.contains(Leanplum.getContext().getPackageName())) {
149-
map.put(key.replace(Values.FILE_PREFIX, ""),
150-
localPath.replace(" ", "%20"));
146+
if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
147+
map.put(key.replace(Values.FILE_PREFIX, ""), filePath);
148+
map.remove(key);
149+
} else {
150+
File f = new File(filePath);
151+
String localPath = "file://" + f.getAbsolutePath();
152+
if (localPath.contains(Leanplum.getContext().getPackageName())) {
153+
map.put(key.replace(Values.FILE_PREFIX, ""),
154+
localPath.replace(" ", "%20"));
155+
}
156+
map.remove(key);
151157
}
152-
map.remove(key);
153158
}
154159
}
155160
return map;

0 commit comments

Comments
 (0)