5

In my SharePoint list i have column called DocType which has values Docx,XLsx,PPT,Link

If you choose any of those I wish to display the Office icons accordingly. As I know these icons are located here C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES

I dont see any way how I can Access it through url? One way could be to put all those needed images in my Project inside layouts folder and show from there.

Is there any better way to do it?

3 Answers 3

1

The icon URL is:

http://your-sharepoint-url/_layouts/15/images/

For example:

http://your-sharepoint-url/_layouts/15/images/icdocx.png
3
  • thats wrong.. have you tried yourself?
    – Happy
    Feb 5, 2016 at 14:16
  • @Happy Of course I tried and can see the icons.
    – Citizen SP
    Feb 5, 2016 at 14:26
  • Threre is no images folder on this path C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
    – Happy
    Feb 5, 2016 at 15:33
0

https://github.com/purtuga/SPImages

has an .ASPX page you drop into a Library which lets you browse all the SharePoint default images

1
  • how it use it programatically ?
    – Happy
    Feb 5, 2016 at 13:22
0

As you're asking about retrieving the icon url programmatically.

In case you use client side programming technique, you can use:

  • JavaScript: SP.Web.mapToIcon()(MSDN)
  • C#: Web.MapToIcon()(MSDN)

For server side programming you can use the static method SPUtility.MapToIcon()(MSDN).

Example in JavaScript for client side programming:

var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();

// the following returns sth. like "icdocx.png"
var iconName = web.mapToIcon('path to document', '', SP.Utilities.IconSize.Size16);

// Perform executeQueryAsync on ctx ...

// OnSucceed you can build the URL for the icon like this:
var imgSrc = _spPageContextInfo.siteAbsoluteUrl + "/" + _spPageContextInfo.layoutsUrl + "/images/" + iconName;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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