Question

Basically, I am writing an extension that replaces the background image of websites. I use CSS to replace the background image with images in the extension. Here is my style.css:

body {
background-image:url(  chrome-extension://moeiggeeiijobkphiljnhlpndjmmpohc/options/smile.jpg ) !important;

}

I don't know why this doesn't work. The url path is correct; if I type it into the address bar, the image smile.jpg will be shown. I also have tried to replace the url with images from other extension that I have installed, like "chrome-extension://pkmbgbnldenjnbgbigpkjokfdfgmmclo/icon-15.png" And it works.

Therefore, I assume that somehow images in my extension can't be accessed by the css. Is there any permission that I need to get?

Was it helpful?

Solution

Yes, you need to define the image as a web-accessible resource. Add this to your manifest file and you should be good to go!:

"web_accessible_resources": [
  "options/smile.jpg"
]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top