Windows 10 reached EOS (end of support) on October 14, 2025. If you are on Windows 10, see this article.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Can't load images on extension

  • 2 replies
  • 1 has this problem
  • 23 views
  • Last reply by Leagon
  • Solved

I'm trying to create an extension that has a menu-like feature, with a "drop-down", which shows more alternatives, however, when I tried to import the image, it didn't work. So I created a "test extension" in which I tried again, in a much more simplified enviroment. However, I don't seem to get this to work (I have included the image in "web_accessible_resources" and used the browser.extension.getURL("image.png"); but It doesn't work), am I doing something wrong, and if so, how are you supposed to do in order to implement images on extensions?

(RenderImage.js): _________________ document.body.style.backgroundImage = browser.extension.getURL("image.png"); _________________ (manifest.json): __________________ {

 "manifest_version": 2,
 "name": "test extension",
 "version": "1.0",
 "web_accessible_resources": [
   "image.png"
 ],
 "content_scripts": [
   {
     "matches": [ "http://example.org/" ],
     "js": [ "RenderImage.js" ]
   }
 ]

} ____________________

(I loaded the extension in the temporary load on about:debugging)

I'm trying to create an extension that has a menu-like feature, with a "drop-down", which shows more alternatives, however, when I tried to import the image, it didn't work. So I created a "test extension" in which I tried again, in a much more simplified enviroment. However, I don't seem to get this to work (I have included the image in "web_accessible_resources" and used the browser.extension.getURL("image.png"); but It doesn't work), am I doing something wrong, and if so, how are you supposed to do in order to implement images on extensions? (RenderImage.js): _________________ document.body.style.backgroundImage = browser.extension.getURL("image.png"); _________________ (manifest.json): __________________ { "manifest_version": 2, "name": "test extension", "version": "1.0", "web_accessible_resources": [ "image.png" ], "content_scripts": [ { "matches": [ "http://example.org/" ], "js": [ "RenderImage.js" ] } ] } ____________________ (I loaded the extension in the temporary load on about:debugging)

Chosen solution

Nevemind, solved it by using document.body.style.backgroundImage = "url('" + browser.extension.getURL("image.png") + "')";

Read this answer in context 👍 0

All Replies (2)

Hi, just to let you know there are no Developers here just Volunteers. Someone ma know the answer.

You can get help at https://stackoverflow.com/ https://discourse.mozilla.org/c/add-ons and some where in a sub of this : https://www.reddit.com/r/firefox/

Chosen Solution

Nevemind, solved it by using document.body.style.backgroundImage = "url('" + browser.extension.getURL("image.png") + "')";