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);
|
||||
}
|
||||
}
|
||||
if (!modeimage && nameinfo && nameinfo[4])
|
||||
let imgPrefixUrl;
|
||||
if (!modeimage && nameinfo && nameinfo[4]) {
|
||||
for (const value of nameinfo[4]) {
|
||||
if (value.startsWith("img:")) {
|
||||
imgPrefixUrl = value.slice(4);
|
||||
break;
|
||||
}
|
||||
if (value.startsWith("ext:")) {
|
||||
extimage = value;
|
||||
break;
|
||||
|
@ -181,7 +186,9 @@ Reflect.defineProperty(HTMLDivElement.prototype, "setBackground", {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (extimage) src = extimage.replace(/^ext:/, "extension/");
|
||||
}
|
||||
if (imgPrefixUrl) src = imgPrefixUrl;
|
||||
else if (extimage) src = extimage.replace(/^ext:/, "extension/");
|
||||
else if (dbimage) {
|
||||
this.setBackgroundDB(dbimage.slice(3));
|
||||
return this;
|
||||
|
@ -225,6 +232,8 @@ HTMLDivElement.prototype.setBackgroundImage = function (img) {
|
|||
.unique()
|
||||
.map((v) => `url("${lib.assetURL}${v}")`)
|
||||
.join(",");
|
||||
} else if (URL.canParse(img)) {
|
||||
this.style.backgroundImage = `url("${img}")`;
|
||||
} else {
|
||||
this.style.backgroundImage = `url("${lib.assetURL}${img}")`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue