Guest User

Untitled

a guest
Oct 21st, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. if (Item.File != null)
  2. {
  3. SPUtility.MapToIcon(Web, Path.GetExtension(Item.File.Name), string.Empty, IconSize.Size16);
  4. }
  5.  
  6. <script type="text/javascript">
  7. function getFileTypeIcon(fName, size) {
  8. var dfd = $.Deferred();
  9. $.ajax({
  10. url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/maptoicon(filename='" + fName + "', progid='', size=" + size + ")",
  11. method: "GET",
  12. headers: { "Accept": "application/json; odata=verbose" },
  13. success: function (data) {
  14. dfd.resolve(_spPageContextInfo.webAbsoluteUrl + "/_layouts/15/images/" + data.d.MapToIcon);
  15. },
  16. error: function (errMsg) {
  17. if (errMsg.responseText) {
  18. dfd.reject(errMsg.responseText);
  19. }
  20. }
  21. });
  22. return dfd.promise();
  23. }
  24. $(document).ready(function() {
  25. // size = 0 for small and 1 for large
  26. getFileTypeIcon('https://someurl/someName.pdf', 1).then(function (result) {
  27. // Write the complete url to file icon
  28. console.log(result);
  29. });
  30. });
  31. </script>
Add Comment
Please, Sign In to add comment