Skip to content

Commit 0823ce5

Browse files
committed
Added "smart thumbnails"
1 parent b718028 commit 0823ce5

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed
573 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

jQuery-File-Upload.MVC3/Upload/FileUploadStatus.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ private void SetValues(string fileName, int fileLength, string fullPath)
3434
delete_url = HandlerPath + "FileTransferHandler.ashx?f=" + fileName;
3535
delete_type = "DELETE";
3636

37+
var ext = Path.GetExtension(fullPath);
38+
3739
var fileSize = ConvertBytesToMegabytes(new FileInfo(fullPath).Length);
38-
if (size > 3) thumbnail_url = "/Content/img/generalFile.png";
40+
if (fileSize > 3 || !IsImage(ext)) thumbnail_url = "/Content/img/generalFile.png";
3941
else thumbnail_url = @"data:image/png;base64," + EncodeFile(fullPath);
4042
}
4143

44+
private bool IsImage(string ext)
45+
{
46+
return ext == ".gif" || ext == ".jpg" || ext == ".png";
47+
}
48+
4249
private string EncodeFile(string fileName)
4350
{
4451
return Convert.ToBase64String(System.IO.File.ReadAllBytes(fileName));

0 commit comments

Comments
 (0)