This commit is contained in:
Bjarke Berg
2020-03-17 15:36:48 +01:00
parent 6d8a23504e
commit 64ba5b6879

View File

@@ -16,6 +16,13 @@ namespace Umbraco.Web.Website.AspNetCore
public static class UmbracoBackOfficeServiceCollectionExtensions
{
public static IServiceCollection AddUmbracoWebsite(this IServiceCollection services)
{
services.AddUmbracoImageSharp();
return services;
}
public static IServiceCollection AddUmbracoImageSharp(this IServiceCollection services)
{
services.AddImageSharpCore(
options =>
@@ -37,8 +44,7 @@ namespace Umbraco.Web.Website.AspNetCore
.SetMemoryAllocator(provider => ArrayPoolMemoryAllocator.CreateWithMinimalPooling())
.Configure<PhysicalFileSystemCacheOptions>(options =>
{
options.CacheFolder = "is-cache";
options.CacheFolder = "../app_data/cache";
})
.SetCache<PhysicalFileSystemCache>()
.SetCacheHash<CacheHash>()
@@ -47,7 +53,6 @@ namespace Umbraco.Web.Website.AspNetCore
.AddProcessor<FormatWebProcessor>()
.AddProcessor<BackgroundColorWebProcessor>();
return services;
}
@@ -66,23 +71,4 @@ namespace Umbraco.Web.Website.AspNetCore
}
}
public class UmbracoResizeWebProcessor : ResizeWebProcessor
{
public new FormattedImage Process(FormattedImage image, ILogger logger, IDictionary<string, string> commands)
{
if(commands.TryGetValue("width", out var command))
{
if (int.TryParse(command, out var width))
{
if (width > 5000)
{
commands.Remove("width");
}
}
}
return Process(image, logger, commands);
}
}
}