mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented image preloading
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Webp;
|
||||
using SixLabors.ImageSharp.Formats;
|
||||
using Berufsschule_HAM.Models;
|
||||
|
||||
namespace Berufsschule_HAM.Helpers;
|
||||
|
||||
@@ -35,4 +36,20 @@ public static class ImageHelper
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task PreloadUsers(IEnumerable<UserModel> userModels, UserImagePreloadType? preloadType)
|
||||
{
|
||||
if (preloadType is null || preloadType == UserImagePreloadType.None) return;
|
||||
|
||||
foreach (UserModel user in userModels)
|
||||
{
|
||||
Console.WriteLine(user.Cn);
|
||||
if (user.JpegPhoto is null) continue;
|
||||
ResizeAndConvertToWebp(user.JpegPhoto, 48);
|
||||
if (preloadType == UserImagePreloadType.FullSized)
|
||||
{
|
||||
ResizeAndConvertToWebp(user.JpegPhoto, 256);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user