Suppose I have an image (image1.png) in site collection1 --> root site --> site assets.

I want to know what would be the relative path of this image in:-

  1. site collection1\root site\sitepage

  2. site collection1\sub site\sitepage

  3. site collection2\root site\sitepage

For example: Suppose there is a masterpage from rootsite inherited by all the sites in the site collection or webapplication. And there is an image on the master page which is present in sitecollection1\rootsite1\site assets\image.png.

Then, how do you reference such a scenario?

  • I do not really grasp how this question in essence is SharePoint specific? I mean, it all comes down to the URLs of the site collections Mar 25 '14 at 9:43
  • @Robert - Site Collections are fairly SharePoint Specific I'd say.
    – Paul Leigh
    Mar 25 '14 at 10:12
  • 1
    Well yes, but if it is a host named site collection there will be no relative URL to talk about. Thereby my comment of this being no different than any other websites :) Mar 25 '14 at 10:13

The relative path only relates to the Site Collection you are in, if you want to go outside of that boundary, you can't use a relative path (unless you employ some form of URL substitution at the Load Balancer / IIS level).

1 & 2 = "/siteassets/image1.png"

3 = "site-collection-url/siteassets/image1.png"

  • OK, so no matter which location I am in the web application, if I want to refer the image on that page then what do I use? Presently we hardcode as: pcname:port/site assets/image.png
    – variable
    Mar 25 '14 at 10:13
  • 2
    @NachiketKamat, there is also the problem with permissions. All uses on all site collection must have read access to the image. Important to not forget this. Normally you try to isolate resource on a site collection level (ergo, upload image resources to every site collection, or if on premise, using the _layouts/images) Mar 25 '14 at 10:17
  • Can you check my updated question?
    – variable
    Mar 26 '14 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.