I wrote an CSS file where I use a picture as background.

I have to Upload the Image I am using with Visual Studio somewhere. At the moment I am doing it like here: http://www.learningsharepoint.com/2013/02/23/deploy-images-in-sharepoint-2013-with-visual-studio-solution-2/

It works but the problem is it only works on the main site and not on subsites because the relative path is different.

So my question is it possible to upload the picture to the root folder. So I can find the image like that "/images/image1.png" at the moment I can find the location where it is uploaded like that ../images/image1.png" but this doesn't work for sub sites.


Yes you can upload the Images directly to the root folder through Module. What you did is right way to upload images to document library in your case you are uploading to "Style Library". Suppose you want to upload to root site level to a "Images" folder

You need to specify the Url of the file "Sample.png" and type of file "Ghostable" please see the below sample code

so that you can access with this "Images/sample.png" in sub sites also

 <Module Name="Module1"  Url="Images" >
<File Path="Module1\Sample.png" Url="Sample.png" Type="Ghostable" IgnoreIfAlreadyExists="FALSE" ReplaceContent="TRUE" /> </Module>
| improve this answer | |

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.