ChromeIcon extension set not working with dictionary
When trying to set a new icon for my chrome extension, it allows me to use the string option. I'm trying to use a dictionary, so chrome might pick the best icon based on the user. Here's what I have so far:
manifest:
"icons": {
"16": "images/icon.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"browser_action": {
"default_icon": {
"16": "images/icon.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
}...
content_script.js:
chrome.browserAction.setIcon({path: {
"16": "images/icon.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
}});
When my code reaches the setIcon code it throws me this error:
Error: Invalid value for argument 1. Property 'path': Value does not match any valid type choices.
I've tried several things, but the only way to do this is to add a string instead of a dictionary. Here are the documents.
source to share
The problem is that Chrome is expecting certain sizes, and if there is anything else it throws this error.
Not very informative, I agree.
Currently the documentation says:
If the number of pixels of the image that fit into one screen is equal
scale
, then the image with the size will be selectedscale * 19
. Only scales 1 and 2 are initially supported.
Thus, he only expects sizes 19
and 38
. Anything else in the dictionary will result in the error above.
Please note that the image does not have to be this exact size; it will scale as needed.
source to share