show file type icon in the custom webpart RRS feed

  • Question

  • Hi,

    I need to add file type icon based on the extension in my custom webpart . i checked in google but I didn’t find exact solution for my requirement.  Currently I have added docview.xml to the style library and parsing its xml to find the file type image, then loading the image from images folder from 15 hive.

    Any simple solution instead of all these process to get the file icon from 15 hive images folder ?

    Wednesday, December 16, 2015 10:57 AM


  • Hi,

    SharePoint has already lots of icons available in the DOCICON.xml file (15-Hive at C:/Program Files/Common Files/Microsoft Shared/web server extensions/15/TEMPLATE/XML)

    Then we can load the image based on file extension "/_layouts/images/icXXX.gif (where icXXX, would be icdoc.gif, idpdf.gif, etc.), similar to your solution.

    Or you can create a JSON file to store the mappings(file type name and image url), then we can use jQuery to create <img src="imageurl"/> in your web part dynamically base on file type.

    Best Regards,


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Edited by Dennis Guo Tuesday, December 22, 2015 10:01 AM
    • Proposed as answer by Patrick_Liang Friday, December 25, 2015 8:45 AM
    • Marked as answer by Patrick_Liang Monday, January 4, 2016 5:03 AM
    Thursday, December 17, 2015 9:52 AM