add search of images
Similar to texts
This commit is contained in:
parent
ca15164def
commit
0df989512c
2 changed files with 41 additions and 0 deletions
23
scripts/strings/image.js
Normal file
23
scripts/strings/image.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
const CONFIG = chrome.runtime.getURL("media/config.icons.json");
|
||||
|
||||
class Image {
|
||||
/* Get the appropriate image path from the configuration.
|
||||
|
||||
@param {string} name The name of the image.
|
||||
*/
|
||||
static get(name, size) {
|
||||
return (fetch(CONFIG)
|
||||
.then((response) => response.json())
|
||||
.then((jsonData) => {
|
||||
let image = {'raw': jsonData[name]};
|
||||
image[`filtered`] = (image[`raw`] && size) ? image[`raw`][String(size)] : image[`raw`];
|
||||
return image[`filtered`];
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
export {Image as default};
|
Loading…
Add table
Add a link
Reference in a new issue