Reputation: 151
I'm creating a CustomizableIntroPart for my Eclipse application. I define my pages using XHTML which works fine. But handling images is causing some trouble. I generate my content using IIntroXHTMLContentProvider, but when I generate an img-tag and set the src attribute images are not displayed. Images might be either in the executing or in some other plugins contributing to the XHTML page.
Element img = dom.createElement("img");
img.setAttribute("src", getApplicationIcon(element));
img.setAttribute("class", "appIcon");
div.appendChild(img);
I couldn't find any documentation on how to specify the source. I tried things like
plugin:my.plugin.id/icons/foo.png
Any help would be appreciated.
Upvotes: 1
Views: 173
Reputation: 10654
In the end, it's a web browser that will display your XHTML content and so it has no notion of "contributed from plugins" right?
But you are using code to process these contributions, and they're coming from either your plugin or other plugins?
If that's the case, I'd use org.osgi.framework.Bundle.getEntry(String)
to get the URL to your image, and then org.eclipse.core.runtime.FileLocator.toFileURL(URL)
to convert it to a file:///
URL. Then use that URL to reference your icons.
Upvotes: 2
Reputation: 1023
I've never used CustomizableIntroPart before, but I have successfully referred to images in different plugins using a prefix of platform:/plugin/...
, like this:
platform:/plugin/my.plugin.id/icons/foo.png
Upvotes: 0