feat: character direct image support.
This commit is contained in:
parent
782aa2eea2
commit
9b4b06a3eb
|
@ -165,8 +165,13 @@ Reflect.defineProperty(HTMLDivElement.prototype, "setBackground", {
|
||||||
nameinfo = get.character(name);
|
nameinfo = get.character(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!modeimage && nameinfo && nameinfo[4])
|
let imgPrefixUrl;
|
||||||
|
if (!modeimage && nameinfo && nameinfo[4]) {
|
||||||
for (const value of nameinfo[4]) {
|
for (const value of nameinfo[4]) {
|
||||||
|
if (value.startsWith("img:")) {
|
||||||
|
imgPrefixUrl = value.slice(4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (value.startsWith("ext:")) {
|
if (value.startsWith("ext:")) {
|
||||||
extimage = value;
|
extimage = value;
|
||||||
break;
|
break;
|
||||||
|
@ -181,7 +186,9 @@ Reflect.defineProperty(HTMLDivElement.prototype, "setBackground", {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extimage) src = extimage.replace(/^ext:/, "extension/");
|
}
|
||||||
|
if (imgPrefixUrl) src = imgPrefixUrl;
|
||||||
|
else if (extimage) src = extimage.replace(/^ext:/, "extension/");
|
||||||
else if (dbimage) {
|
else if (dbimage) {
|
||||||
this.setBackgroundDB(dbimage.slice(3));
|
this.setBackgroundDB(dbimage.slice(3));
|
||||||
return this;
|
return this;
|
||||||
|
@ -225,6 +232,8 @@ HTMLDivElement.prototype.setBackgroundImage = function (img) {
|
||||||
.unique()
|
.unique()
|
||||||
.map((v) => `url("${lib.assetURL}${v}")`)
|
.map((v) => `url("${lib.assetURL}${v}")`)
|
||||||
.join(",");
|
.join(",");
|
||||||
|
} else if (URL.canParse(img)) {
|
||||||
|
this.style.backgroundImage = `url("${img}")`;
|
||||||
} else {
|
} else {
|
||||||
this.style.backgroundImage = `url("${lib.assetURL}${img}")`;
|
this.style.backgroundImage = `url("${lib.assetURL}${img}")`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue