add local URL to local images
This commit is contained in:
parent
54ec8714ee
commit
1aa887cab1
1 changed files with 14 additions and 0 deletions
|
@ -12,6 +12,20 @@ class Image {
|
|||
.then((jsonData) => {
|
||||
let image = {'raw': jsonData[name]};
|
||||
image[`filtered`] = (image[`raw`] && size) ? image[`raw`][String(size)] : image[`raw`];
|
||||
|
||||
// Set the appropriate URL.
|
||||
if (typeof image[`filtered`] == `string` && !image[`filtered`].includes(`://`)) {
|
||||
image[`filtered`] = chrome.runtime.getURL(image[`filtered`]);
|
||||
} else if (((typeof image[`filtered`]).includes(`obj`) && image[`filtered`] != null && !Array.isArray(image[`filtered`])) ? (Object.keys(image[`filtered`]).length) : false) {
|
||||
Object.keys(image[`filtered`]).forEach((key) => {
|
||||
image[`filtered`][key] = (!image[`filtered`][key].includes(`://`)) ? chrome.runtime.getURL(image[`filtered`][key]) : image[`filtered`][key];
|
||||
});
|
||||
} else if (Array.isArray(image[`filtered`])) {
|
||||
image[`filtered`] = image[`filtered`].map((element) => {
|
||||
return chrome.runtime.getURL(element);
|
||||
});
|
||||
};
|
||||
|
||||
return image[`filtered`];
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue