Browse Source

fix the cover image not showing the problem on blogging module

pull/10068/head
Berkan Sasmaz 4 years ago
parent
commit
7cf931ca28
  1. 11
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/ImageFormatHelper.cs

11
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/ImageFormatHelper.cs

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
namespace Volo.Blogging.Areas.Blog.Helpers
{
@ -16,8 +17,14 @@ namespace Volo.Blogging.Areas.Blog.Helpers
public static bool IsValidImage(byte[] fileBytes, ICollection<ImageFormat> validFormats)
{
var imageFormat = GetImageRawFormat(fileBytes);
return validFormats.Contains(imageFormat);
// System.Drawing only works on windows => https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image?view=net-5.0#remarks
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var imageFormat = GetImageRawFormat(fileBytes);
return validFormats.Contains(imageFormat);
}
return true;
}
}
}

Loading…
Cancel
Save