0

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?

Muath
  • 4,351
  • 12
  • 42
  • 69
user226629
  • 79
  • 1
  • 1
  • 6
  • did you checked that extension name was of the correct type ? smile.jpg, but it's in fact a png hold in the file .It happened to me before. – G-Cyrillus Jun 26 '13 at 17:35
  • - GCyrillus, The type is correct. As I said, if I type it into my address bar, the image can be shown. If the type is wrong, then the image can't be shown. – user226629 Jun 26 '13 at 17:37
  • i mean, open file in text editor and check that it is a real jpeg and not a png or else. in other words, are your extension and image/type are coherent ? – G-Cyrillus Jun 26 '13 at 17:52
  • Yes, it is a real jpg/jpeg image, I downloaded it from a website, and have never changed its type. – user226629 Jun 26 '13 at 18:03
  • oki, i have no more clue. – G-Cyrillus Jun 26 '13 at 18:06

1 Answers1

1

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"
]