Reputation: 736
I am trying to port a chrome extension to firefox.
In chrome I had been accessing a certain image using :
chrome.extension.getURL('img/full_logo.png')
In firefox I tried to achieve the same with the following :
var self = require("sdk/self");
self.data.url('img/full_logo.png');
But the firefox console gives error saying require is not defined which i understand is not a javascript function.
What is this require function? How can I get the URL of the image for my firefox add-on? Any valuable links are also be appreciated.
Upvotes: 1
Views: 177
Reputation: 6735
Why access the image from addon code if you know it's name? When you can directly link to it from your content markup.
Consider this directory structure:
├── data
│ ├── html
│ │ └── ui.html
│ ├── images
│ │ └── image.png
│ └── js
│ └── contentScript.js
Inside ui.html
use below to use the image ..
<img src="../images/image.png"></img>
Upvotes: 2