0

I have uploaded two Resources - a.HTML and b.PNG. In a I'd like to display b and according to this blog I should go like this.

<img src="$webresource:b.png">

However, I'd like to know if there's an other syntax (preferably one that doesn't includes the $webresource: part). I've tried with some different combinations but didn't really succeeded.

4
  • 1
    If this answered your issue, please mark it as answered. Doing so will help encourage others to assist in any future questions you may have.
    – Greg Owens
    Dec 11, 2012 at 15:36
  • @GregOwens What do you mean by "this answer"? This is my question, not an answer... I'm not sure what you'd like me to mark as answered.
    – user1672517
    Dec 11, 2012 at 18:08
  • Bad choice of words. If your question has been answered, which I believe it is by my response below, then mark that as answered ;)
    – Greg Owens
    Dec 11, 2012 at 19:14
  • @GregOwens It sure was. Sorry for being slow. And the choice of Words wasn't bad. I was just very tired and didn't connect the dots properly.
    – user1672517
    Dec 12, 2012 at 17:44

1 Answer 1

4

The article you link to explains how to reference a web resource from within the Ribbon or Site Map. This is different to your goal which is to reference one web resource from another.

The CRM SDK states:

When referencing a web resource from areas that do not support using the $webresource: directive,...

(Note that Web Resources themselves do not support the $webresource: directive)

...a relative URL can be used. To enable this, we recommend that you use a consistent naming convention for the web resources that reflect a virtual file structure. The solution publisher’s customization prefix will always be included as a prefix to the name of the web resource. This can represent a virtual ”root” folder for all web resources added by that publisher. You can then use the forward slash character (/) to simulate a folder structure that will be honored by the web server.

So if you have two web resources called:

  1. new_/html/mypage.html
  2. new_/img/myimage.png

In mypage.html you can refer to the image thusly:

<img src="../img/myimage.png"/>

By implication, if your resources (a.HTML and b.PNG) do not have virtual paths, it should be sufficient to reference the image like this (though I strongly recommend using the aforementioned Virtual Path convention):

<img src="b.PNG"/>
1
  • 1
    Just a quick note - your <img> tags should use forward slashes, and in the final example the initial "./" is implied. So <img src="b.PNG"> is sufficient.
    – rossp
    Dec 4, 2012 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.