I am adding images to style image collection images through module. Here is my element.xml from my module

<Module Name="MyModule" Url="SiteCollectionImages" RootWebOnly="TRUE">
   <File Path="MyModule\test.png" Url="MyImages/test.png" Type="GhostableInLibrary" />

Images are uploaded successfully...

In my master page is trying to refer images are below

<img src="< %$ SPUrl: ~sitecollection/sitecollectionimages/MyImages/test.png %>" border="0" /> 

But i get error in console that its internal server error and gives path like this


How exactly to refer this image?

I have put my javascript in style library and referring like this successfully

<SharePoint:scriptlink ID="ScriptLink6" runat="server" Name="~sitecollection/Style Library/Intranet/jquery-1.7.1.min.js"/>

Why its not picking image?

1 Answer 1


Please try below code

<img src="<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/sitecollectionimages/MyImages/test.png%>' />" />
  • oh it worked . why we need to use asp literal control?
    – Happy
    Commented Apr 8, 2016 at 9:49
  • That's great if it works for you. Please mark the answer so others can get benefit of it.
    – Hardik
    Commented Apr 8, 2016 at 9:50
  • but why we need to use it like this?
    – Happy
    Commented Apr 8, 2016 at 9:51
  • The Literal Control is similar to the Label Control as they both are used to display static text on a web page & as we have put the SPUrl than it will append the SharePoint URL with this static code. :)
    – Hardik
    Commented Apr 8, 2016 at 9:53
  • If you satisfied than please mark it as correct so others can get benefit of it.
    – Hardik
    Commented Apr 8, 2016 at 9:54

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.