2

I'm trying to get my relative path for my image, as this site will be re-used on different sites on the site collection.

and the sharepoint url would been this sitecollection.sharepoint.com/topsite/subsite. Thats the reason why I can't use the full URL. as the subsite name would be different every time. But the image will always be in the same document library on the subsite.

<img src="./Shared%20Documents/enddate.png" />

tl;dr need the relative url path for the image.

2
  • Have you tried <img src="/Shared%20Documents/enddate.png" />? Commented Nov 13, 2014 at 12:41
  • <img src="../SiteAssets/enddate.png"> did actually work. But thanks anyways! Commented Nov 14, 2014 at 7:37

1 Answer 1

2

You can do it as

<img src='<SharePoint:EncodedLiteral runat="server" text="<%$SPUrl:~site/Shared%20Documents/enddate.png%>" EncodeMethod="HtmlEncode"/>' alt="" />

Your Answer

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

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