<script type="text/javascript">
var iconName;
function getDocumentTypeIcon() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
iconName
= web.mapToIcon('test1.docx', '', SP.Utilities.IconSize.Size16);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));
}
function onSuccessMethod(sender, args) {
var iconUrl = _spPageContextInfo.siteAbsoluteUrl
+ "/_layouts/images/" + iconName.m_value;
alert(iconUrl);
}
function onFailureMethod(sender, args) {
alert("Error: " + args.get_message());
}
ExecuteOrDelayUntilScriptLoaded(getDocumentTypeIcon, 'sp.js');
</script>
Document
type icon names take the form of IC<Document Type>.gif (Ex: icdocx.gif).
The information about which icon is displayed for which document type in stored
in the DOCICON.XML file stored in /TEMPLATE/XML folder in the SharePoint hive.
2 comments:
Thank you for finding out.
Thanks - a great tip!
Post a Comment