Skip to content

Commit

Permalink
Accept .ico file as image.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnetjunky committed Jan 8, 2013
1 parent 54c3c98 commit c5348bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Website/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public static class FileHelper
".DLL", ".EXE", ".WINMD", ".CHM", ".PDF",
".DOCX", ".DOC", ".RTF", ".PDB", ".ZIP",
".RAR", ".XAP", ".VSIX", ".NUPKG", ".SNK",
".PFX", ".ICO"
".PFX"
};

internal static readonly string[] ImageFileExtensions = new[]
{
".PNG", ".GIF", ".JPG", ".BMP", ".JPEG"
".PNG", ".GIF", ".JPG", ".BMP", ".JPEG", ".ICO"
};

public static bool IsBinaryFile(string path)
Expand All @@ -38,6 +38,12 @@ public static string GetImageMimeType(string filePath)
string extension = Path.GetExtension(filePath).ToLowerInvariant();
if (ImageFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
if (extension == ".ico")
{
// IE will only render .ico file if the mime type is "image/x-icon"
return "image/x-icon";
}

return "image/" + extension.Substring(1); // omit the dot in front of extension
}

Expand Down
2 changes: 1 addition & 1 deletion Website/Views/PackageFiles/Contents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
function isImage(path) {
var extension = getEffectiveExtension(path);
return extension == 'jpg' || path == 'gif' || extension == 'png' || extension == 'bmp' || extension == 'jpeg';
return extension == 'jpg' || path == 'gif' || extension == 'png' || extension == 'bmp' || extension == 'jpeg' || extension == 'ico';
}
function determineBrush(path) {
Expand Down

0 comments on commit c5348bf

Please sign in to comment.