Allow data URI scheme for custom images (#1196)

* Allow data URL external images

* fix

* removed inconsistency
This commit is contained in:
Ruichka 2025-03-08 16:51:48 +03:00 committed by GitHub
parent f859439fc8
commit 8131f25456
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 32 additions and 32 deletions

View file

@ -131,7 +131,7 @@ class Battle {
for (const u of options.military) {
const label = capitalize(u.name.replace(/_/g, " "));
const isExternal = u.icon.startsWith("http");
const isExternal = u.icon.startsWith("http") || u.icon.startsWith("data:image");
const iconHTML = isExternal ? `<img src="${u.icon}" width="15" height="15">` : u.icon;
headers += `<th data-tip="${label}">${iconHTML}</th>`;
}
@ -148,7 +148,7 @@ class Battle {
const distance = (Math.hypot(this.y - regiment.by, this.x - regiment.bx) * distanceScale) | 0; // distance between regiment and its base
const color = state.color[0] === "#" ? state.color : "#999";
const isExternal = regiment.icon.startsWith("http");
const isExternal = regiment.icon.startsWith("http") || regiment.icon.startsWith("data:image");
const iconHtml = isExternal
? `<image href="${regiment.icon}" x="0.1em" y="0.1em" width="1.2em" height="1.2em"></image>`
: `<text x="50%" y="1em" style="text-anchor: middle">${regiment.icon}</text>`;