I want to display an image on a page within my Google Chrome extension, but I want to store the image within a folder called "images" within my chrome extension. How do I link to this image? What URL do I use?
I need it to go here (in place of "URL"). How do I implement it?
<a href="URL"><img src="URL" /></a>
answer did not work; still need help.
var url = chrome.extension.getURL('/folder/file.png');
https://code.google.com/chrome/extensions/extension.html#method-getURL
Update: Added working example.
In index.html
:
<img id='someid' src="">
<script>
var img = document.getElementById('someid');
img.src = chrome.extension.getURL('/images/google.png');
</script>
In manifest.json
:
{
"name": "My Extension",
"version": "1"
}
Opening chrome-extension://xyz/index.html
shows the image as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With