diff --git a/src/Umbraco.Web.UI/config/imageprocessor/processing.config b/src/Umbraco.Web.UI/config/imageprocessor/processing.config
index dddcddb0bd..da9b6fa180 100644
--- a/src/Umbraco.Web.UI/config/imageprocessor/processing.config
+++ b/src/Umbraco.Web.UI/config/imageprocessor/processing.config
@@ -2,37 +2,70 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Umbraco.Web.Website/AspNetCore/UmbracoWebsiteServiceCollectionExtensions.cs b/src/Umbraco.Web.Website/AspNetCore/UmbracoWebsiteServiceCollectionExtensions.cs
index 5fb2825269..aeae455294 100644
--- a/src/Umbraco.Web.Website/AspNetCore/UmbracoWebsiteServiceCollectionExtensions.cs
+++ b/src/Umbraco.Web.Website/AspNetCore/UmbracoWebsiteServiceCollectionExtensions.cs
@@ -1,5 +1,15 @@
+using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using SixLabors.ImageSharp.Processing;
+using SixLabors.ImageSharp.Web;
+using SixLabors.ImageSharp.Web.Caching;
+using SixLabors.ImageSharp.Web.Commands;
using SixLabors.ImageSharp.Web.DependencyInjection;
+using SixLabors.ImageSharp.Web.Middleware;
+using SixLabors.ImageSharp.Web.Processors;
+using SixLabors.ImageSharp.Web.Providers;
+using SixLabors.Memory;
namespace Umbraco.Web.Website.AspNetCore
{
@@ -7,11 +17,58 @@ namespace Umbraco.Web.Website.AspNetCore
{
public static IServiceCollection AddUmbracoWebsite(this IServiceCollection services)
{
- services.AddImageSharp();
-
+ services.AddUmbracoImageSharp();
return services;
}
+ public static IServiceCollection AddUmbracoImageSharp(this IServiceCollection services)
+ {
+ services.AddImageSharpCore(
+ options =>
+ {
+ options.Configuration = SixLabors.ImageSharp.Configuration.Default;
+ options.MaxBrowserCacheDays = 7;
+ options.MaxCacheDays = 365;
+ options.CachedNameLength = 8;
+ options.OnParseCommands = context =>
+ {
+ RemoveIntParamenterIfValueGreatherThen(context.Commands, ResizeWebProcessor.Width, 5000);
+ RemoveIntParamenterIfValueGreatherThen(context.Commands, ResizeWebProcessor.Height, 5000);
+ };
+ options.OnBeforeSave = _ => { };
+ options.OnProcessed = _ => { };
+ options.OnPrepareResponse = _ => { };
+ })
+ .SetRequestParser()
+ .SetMemoryAllocator(provider => ArrayPoolMemoryAllocator.CreateWithMinimalPooling())
+ .Configure(options =>
+ {
+ options.CacheFolder = "../app_data/cache";
+ })
+ .SetCache()
+ .SetCacheHash()
+ .AddProvider()
+ .AddProcessor()
+ .AddProcessor()
+ .AddProcessor();
+
+ return services;
+ }
+
+ private static void RemoveIntParamenterIfValueGreatherThen(IDictionary commands, string parameter, int maxValue)
+ {
+ if (commands.TryGetValue(parameter, out var command))
+ {
+ if (int.TryParse(command, out var i))
+ {
+ if (i > maxValue)
+ {
+ commands.Remove(parameter);
+ }
+ }
+ }
+ }
}
+
}