SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add the following feature to my Web Template. - Add a picture library with some default pictures in it

First step would be creating a custom list from the type picture library. But how would you be able to add some pictures (items) to this library?

share|improve this question
up vote 1 down vote accepted

Create a module, call it e.g. Pictures and add pictures to it. The elements.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <Module Name="Pictures" Url="MyPictureLibrary">
    <File Path="Pictures\pic1.png" Url="pic1.png" Type="GhostableInLibrary"/>
    <File Path="Pictures\pic2.png" Url="pic2.png" Type="GhostableInLibrary" />

Add the module to a web scoped feature. (Assuming you call your library MyPictureLibrary and the feature that deploys this module is activated in the same web as the library)

Edit: Or do it through code like Rob suggested.

share|improve this answer
Thanks Tarjeieo! – Wim Hill Aug 2 '11 at 14:38

Once you have you're library created, you could use:


To add the files to the root folder of the library. The Add method has numerous overrides depending on how you want to add the file (byte array versus stream, with or without metadata, etc.)

I can provide a more complete code snippet if needed...let me know.

share|improve this answer
Rob, thanks for your answer but I'm looking into a solution where this can be done as part of my List Instance process. I don't know if there are some options through the element.xml file to include files which were provisioned to e.g. an image folder under the _layouts folder? If the only option is code behind It would be nice to have some more details as you propsed. Thanks in advance! – Wim Hill Aug 2 '11 at 14:09
If you want to do it as part of the element.xml then tarjeieo's answer is the right way to go. From a code standpoint, you can create the list in a feature receiver and then add the files as noted above. – Rob D'Oria Aug 2 '11 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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