Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Item.File != null)
- {
- SPUtility.MapToIcon(Web, Path.GetExtension(Item.File.Name), string.Empty, IconSize.Size16);
- }
- <script type="text/javascript">
- function getFileTypeIcon(fName, size) {
- var dfd = $.Deferred();
- $.ajax({
- url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/maptoicon(filename='" + fName + "', progid='', size=" + size + ")",
- method: "GET",
- headers: { "Accept": "application/json; odata=verbose" },
- success: function (data) {
- dfd.resolve(_spPageContextInfo.webAbsoluteUrl + "/_layouts/15/images/" + data.d.MapToIcon);
- },
- error: function (errMsg) {
- if (errMsg.responseText) {
- dfd.reject(errMsg.responseText);
- }
- }
- });
- return dfd.promise();
- }
- $(document).ready(function() {
- // size = 0 for small and 1 for large
- getFileTypeIcon('https://someurl/someName.pdf', 1).then(function (result) {
- // Write the complete url to file icon
- console.log(result);
- });
- });
- </script>
Add Comment
Please, Sign In to add comment