How to include Pictures when your site is created

This can be achieved using a feature or as part of the onet.xml file for a site definition.   I will use a feature as this is my preferred approach and it can also be reused across multiple sites.

1.  Create feature

Create a new directory under the 12 hive, and create two new files feature.xml and elementManifest.xml (you can copy from an existing feature to make this easier).  

Edit the feature file and add the contents as below,  this will be the basis of the feature.  You will need to provide a unique GUID.  Use guidgen from Visual Studio to generate you GUID.

<Feature  Title=”Add Picture Feature” Id=”21BC0000-805F-4151-A41C-5FE5B66ACBDA”
          Description=”Add Picture Demo” Version=”″
          Scope=”Web” Hidden=”TRUE” DefaultResourceFile=”core”
    <ElementManifest Location=”elementManifest.xml” />

2. Create a subdirectory under the feature folder

When you upload an image to a picture library SharePoint creates two additional versions of that image in JPEG format that it displays in the thumbnail and preview screens.   When adding images we need to also add these and they will be renamed with a .jpg extension as shown:

MyPicture.gif  ->  MyPicture_gif.jpg

MyPicture.jpg -> MyPicture_jpg.jpg

Create a subdirectory below the feature called “Picture Library” and then create two folders beneath this call “t” and “w”.

Tip:  Upload the image to an existing library to generate the thumbnail and preview images.

This will give you a directory structure similar to this


Copy the original image to the “Picture Library” directory, and the thumbnail and preview images to the “t” and “w” sub directories respectively.

3. Add the files to the feature.xml and elementManifest.xml files


Add the images files to your feature.xml file as below.

<Feature  Title=”Add Picture Feature” Id=”21BC0000-805F-4151-A41C-5FE5B66ACBDA”
          Description=”Add Picture Demo” Version=”″
          Scope=”Web” Hidden=”TRUE” DefaultResourceFile=”core”
    <ElementManifest Location=”elementManifest.xml” />
    <ElementFile Location=”Picture Library\21appsLogo_large.jpg” />
    <ElementFile Location=”Picture Library\w\21appsLogo_large_jpg.jpg” />
    <ElementFile Location=”Picture Library\t\21appsLogo_large_jpg.jpg” />



The elements manifest file defines the picture library we are creating and the  source and target for each of the files. 

<Elements xmlns=””>
    <ListInstance FeatureId=”00bfea71-52d4-45b3-b544-b1c71b620109″ TemplateType=”109″ Title=”Picture Library” Url=”Picture Library” />
    <Module Name=”PictureLibrary” List=”109″ Url=”Picture Library” Path=”Picture Library”>
    <File Url=”21appsLogo_large.jpg” Type=”GhostableInLibrary” />
  <Module Name=”PictureLibrary1″ List=”109″ Url=”Picture Library/_t” Path=”Picture Library\t”>
    <File Url=”21appsLogo_large_jpg.jpg” />
  <Module Name=”PictureLibrary2″ List=”109″ Url=”Picture Library/_w” Path=”Picture Library\w”>
    <File Url=”21appsLogo_large_jpg.jpg” />
  <Module Name=”Remainder” Url=”” Path=””>

Note: three modules are used as the URL (path) the files are copied from and to are different. 

The thumbnail and preview images are located in /_t and /_w folders within a picture library.

In this example we have also created the picture library in which we will add the picture

    <ListInstance FeatureId=”00bfea71-52d4-45b3-b544-b1c71b620109″ TemplateType=”109″ Title=”Picture Library” Url=”Picture Library” />

4. Install the feature

Using stsadm.exe install the feature

stsadm -o installfeature -name AddPictureFeature

In our example we have hidden the feature (Hidden=”True”) as we will add this directly to a sites onet.xml file so that it is created upfront.  This is often referred to as Feature Stapling.

5.  Update the site defintions onet.xml

In this example I will add the feature to the STS site definition, 

Warning – it is always recommended to make copies and change these as future service packs may overwrite your changes and you could effect you support.

Add the feature to the <WebFeatures> section of the sites onet.xml.  Depending on your site definition you may need to add this to multiple configurations.

<!– Add Picture Feature –>
<Feature ID=”00bfea71-52d4-45b3-b544-b1c71b620109″ />

6.  Recycle and Create the site

Do an IISreset (as your doing this in dev, aren’t you!) and create a new Team Site (or the site you altered).

7. Create a site test

After creating the site you should now see a Picture Library with one image automatically included.


Clicking on the library should show your image with the thumbnail.


Hope this is of some help,  it’s fairly basic stuff but sometimes these simple things are easily forgotten.

This entry was posted in Development, SharePoint and tagged , . Bookmark the permalink.
  • Anonymous


    how will I be able to include an image in the images library to every site I have created and I will be creating?

    can u send me your response to

  • Andrew Woodward

    The blog post show how to include images for new sites, if you want to do this on existing templates you will need to look at using Feature Stapling.

    For existing sites you could write a simple tool that does this for you using the object model.

  • Anonymous


    Thanks andrew, so your suggesting that I just create a tool cause creating features wont affect any existing sites right?
    Im a newbie on MOSS custom code.. is there an article that I can read on how to create tools that can be executed on server? Should I use webpart? any more suggestions?

  • Anonymous

    You can also use the same file as the original picture for thumbnail and preview. Add the Path attribute to the File element in the thumbnail and preview modules and point the Path to the original picture like this: File Url=”21appsLogo_large_jpg.jpg” Path=”21appsLogo_large.jpg”

  • Cris

    Hi there!

    Has this steps changed to Sharepoint 2010?

    Thanks in advance


  • Pingback: Create Custom Lists in CAML based on existing List Templates

  • Abhishek072015

    Hi Andrew,

    Great Post, its really helpfull and i did the same as starter. Today i tried creating a picture library with the same steps, it fails to include images with hyperlink attached to the library in list instance. Could you please elaborate which are the steps need to be changed while working in VS 2010