Added support for background images

This commit is contained in:
M66B 2022-03-29 21:59:25 +02:00
parent 864b014f3c
commit 88bc43f836
1 changed files with 16 additions and 0 deletions

View File

@ -653,6 +653,22 @@ public class HtmlHelper {
for (String key : keys) {
String value = kv.get(key);
switch (key) {
case "background-image":
// https://developer.mozilla.org/en-US/docs/Web/CSS/background-image
String url = value.replace(" ", "");
int us = url.indexOf("url(");
int ue = url.indexOf(')', us + 4);
if (us >= 0 && ue > us) {
url = url.substring(us + 4, ue);
if ((url.startsWith("'") && url.endsWith("'")) ||
(url.startsWith("\"") && url.endsWith("\"")))
url = url.substring(1, url.length() - 1);
Element img = document.createElement("img")
.attr("src", url);
element.prependElement("br");
element.prependChild(img);
}
break;
case "color":
case "background":
case "background-color":