Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension image assets not showing up (manifest version 2)

I've just been updating a chrome plugin to manifest version 2. I've had no issues with permissions relating to javascript but the plugin has some image assets packaged with it that are no longer showing up.

The two specific cases are in popup notifications when the user interacts with the plugin in certain ways and some small images the plugin inserts into certain pages. In both cases the images are packaged with the plugin. I'm having no issue with the plugin loading images from external resources. My object-src setting in the content_security_policy includes 'self'.

What am I missing? I can open the images if I navigate to them directly via "chrome-extension:///some_img.png" so they are definitely there. I've used the webkit inspector and finding the img that has been inserted, right clicking on the img src and opening in a new tab also shows the img so the urls being inserted are correct (which they should be, I'm using the chrome.extension.getURL function).

UPDATE:

Setting img-src in the content_security_policy also did nothing. I don't know if chrome even uses that particular option but it's in the W3C spec.

like image 382
Endophage Avatar asked Aug 07 '12 18:08

Endophage


People also ask

Is manifest V2 still supported?

Manifest V2 support ends in June of 2023 for all Chromium-based browsers. An overview of the changes involved, as described in Overview of Manifest V3 - Chrome Developers: Service workers will replace background pages. Network request modifications will be handled by the new declarativeNetRequest API.

Is manifest V2 deprecated?

"Manifest version 2 is deprecated, and support will be removed in 2023."

How do I see chrome manifest extensions?

Open chrome://version/ and find the "Profile Path:` field. Open that folder up. All your extensions are here, with typically readable source.

How do I add an extension to a picture?

Click the plus button , and select Image extension. From the “Add to” drop-down menu, select a campaign or ad group you want to add your image extensions to. Click the plus button next to “Images”, then select an image source from the top of the dialog box.


1 Answers

After digging through the changelog for the last few chrome versions, I came across a new (added in Chrome 18) manifest option web_accessible_resources. This needs to be added to your manifest with a value that's a list of strings. The strings are paths in you plugin's directory to resources (imgs etc...) that you want to be accessible within web pages (or importantly, chrome desktop notifications). Adding this parameter to my manifest gave permissions for the necessary images to be loaded.

like image 129
Endophage Avatar answered Oct 16 '22 21:10

Endophage