SharePoint 2013 Custom Picture Library Creation & Deployment

I have had many painful experiences attempting to deploy picture libraries with custom fields from Visual Studio with previous versions of SharePoint but with 2013 I have come up with this method (which may not be the best but seems to work consistently). With any luck this will aid someone else and save them the time I have wasted previously. This guide is for SharePoint 2013 and the solution is developed in Visual Studio 2013, I have not tested this method with any other combination so outside of this environment you’re on your own.

  1. Open Visual Studio 2013 and create and SharePoint 2013 – Empty Project
    1. Create Empty Project
  2. Enter the name of the local URL of the SharePoint site you are going to test against, for this solution select Deploy as a sandboxed solution as there is no code required.
    2. Project Deployment
  3. As we are not developing any code for this solution set the project property Include Assembly in Package to False.
    3. Project Properties
  4. Now we have our empty SharePoint project ready to go, in Solution Explorer right click the project name and select Add > New Item. Under the Office/SharePoint templates select List, give the list a name and click Add
    4. Add New Item
  5. On the list settings screen select Create a customizable list template and a list instance of it. From the templates available in the drop down select Document Library
    5. List Settings
  6. All going well the list has been added to the project and schema designer window for the new list has opened. Currently this is the schema for a document library so the content type needs to be changed. Click the Content Type button
    6. Select Content Types
  7. In the Content Type Settings window right click the current default Document type and select Delete, in this example I also removed the Folder content type as it was not required
    7. Content Type Settings Remove
  8. Click in the empty Content Type Name box if it is not automatically selected for you and select Picture from the drop down list and click OK
    8. Content Type Settings Select
  9. In the main window you can now see a different set of columns reflecting the content type change. In the solution explorer you can also see a bunch of files have been added under the list, select all the files under the list (not list instance) except Elements.xml (include Schema.xml, not selected in this screenshot) and delete them
    9. Content Type Updated
  10. Next the files that were deleted need to be replaced with picture library ones. Right click the list name in Solution Explorer and select Add > Existing Item.
    Next browse to the SharePoint 15 hive features and locate the Picture Library feature (default path):C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES\PictureLibrary\Select all the files in the PicLib directory and click OK
    10. Add Supporting Files
  11. The screenshot below shows the above location and files contained in the PicLib directory in Windows Explorer
    11. Hive Files
  12. The Solution Explorer list structure should now look as follows. Click the Show All Files button at the top of the Solution Explorer window, you should now see the SharePoint managed file SharePointProjectItem.spdata under the list definition, open it up
    12. Solution with files
  13. The contents of the file should be similar to the one shown below. This file defines which files are included in the list feature when SharePoint packages the WSP solution, we need to adjust this to include the files we just added so they are deployed
    13. SharePointProjectItem
  14. Copy the existing line and create a new entry for each file to be included.Note it is very important to make sure only the Elements.xml file has a type attribute of ElementManifest, all other files should have a type of ElementFile.You should end up with the file looking similar to the screenshot below
    14. SharePointProjectItem Updated
  15. Next open the Elements.xml file from under the list and update the ListTemplate Type attribute to 109 as shown (109 is the type of the Picture Library)
    15. Update List Elements
  16. Now open the Schema.xml file from under the list. Update the List attributes for Title and URL to exactly match the ListTemplate Name attribute from the Elements.xml file.
    Add the EnableContentTypes attribute with a value of TRUE.
    Finally Edit the ContentTypes node so it matches the screenshot shown. Note there will be an extra item required if folders are required
    16. Update List Schema
  17. The list definition is now configured, on to the list instance. Open the Elements.xml file and update the TemplateType attribute to 109 to match the list definition. At this point save everything that is open and close and reopen the Visual Studio solution, this is required for Visual Studio to pick up the changes we made to the SharePoint project item file we made earlier.Note if this is not done the new files will not be packaged and the feature cannot be activated.After closing and reopening you can make any customizations required to the list and add any custom field columns required using the schema designer. This can be opened by double clicking on the list name in Solution Explorer
    17. Update List Instance
  18. Once all customizations have been made you are ready to deploy and test the solution right click the project in Solution Explorer and select Deploy. Visual Studio will now build and package the solution and attempt to deploy and activate the feature on the SharePoint site defined at the start
    18. Deploy
  19. In your browser open the SharePoint site and navigate to the Site Contents, your list should be listed with a new! flag next to it, click the list
    19. New Picture Library
  20. Your Picture Library is now deployed and ready to go!
    20. Ready For Action

8 Replies to “SharePoint 2013 Custom Picture Library Creation & Deployment”

  1. Hi Simon,

    Thank you for your great post. I was trying to work with custom schemas for days but could not do it until see your very nice post :)!

    Best regards,

  2. Dear Simon,

    Its very good post and very well explained in detail and success with creating new library. However, i noticed that the Picture Library icon is different from original SharePoint picture library. Can you have any idea how we can change that too.

Leave a Reply

Your email address will not be published. Required fields are marked *