diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index ecdaac53b2..2a97a24fdd 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -271,7 +271,7 @@ namespace Umbraco.Tests.Integration.Testing services.AddSignalR(); - services.AddUmbracoWebComponents(); + services.AddUmbracoWebComponents(Configuration); services.AddUmbracoRuntimeMinifier(Configuration); services.AddUmbracoBackOffice(); services.AddUmbracoBackOfficeIdentity(); diff --git a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs index 635594a77d..10f214a522 100644 --- a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs @@ -69,7 +69,7 @@ namespace Umbraco.Web.Common.Builder => builder.AddWith(nameof(WithRuntimeMinifier), () => builder.Services.AddUmbracoRuntimeMinifier(builder.Config)); public static IUmbracoBuilder WithWebComponents(this IUmbracoBuilder builder) - => builder.AddWith(nameof(WithWebComponents), () => builder.Services.AddUmbracoWebComponents()); + => builder.AddWith(nameof(WithWebComponents), () => builder.Services.AddUmbracoWebComponents(builder.Config)); public static IUmbracoBuilder WithWebServer(this IUmbracoBuilder builder) => builder.AddWith(nameof(WithWebServer), () => diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs index 37ac5c7683..fdab7d7169 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs @@ -25,17 +25,14 @@ namespace Umbraco.Extensions /// Registers the web components needed for Umbraco /// /// + /// /// - public static IServiceCollection AddUmbracoWebComponents(this IServiceCollection services) + public static IServiceCollection AddUmbracoWebComponents(this IServiceCollection services, IConfiguration configuration) { services.ConfigureOptions(); services.TryAddEnumerable(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); - - // TODO: We need to avoid this, surely there's a way? See ContainerTests.BuildServiceProvider_Before_Host_Is_Configured - var serviceProvider = services.BuildServiceProvider(); - var imagingSettings = serviceProvider.GetService>().Value; - services.AddUmbracoImageSharp(imagingSettings); + services.AddUmbracoImageSharp(configuration); return services; } @@ -44,10 +41,12 @@ namespace Umbraco.Extensions /// Adds Image Sharp with Umbraco settings /// /// - /// + /// /// - public static IServiceCollection AddUmbracoImageSharp(this IServiceCollection services, ImagingSettings imagingSettings) + public static IServiceCollection AddUmbracoImageSharp(this IServiceCollection services, IConfiguration configuration) { + var imagingSettings = configuration.GetSection(Core.Constants.Configuration.ConfigImaging) + .Get() ?? new ImagingSettings(); services.AddImageSharp(options => { @@ -62,7 +61,7 @@ namespace Umbraco.Extensions return Task.CompletedTask; }; - options.OnBeforeSaveAsync = _ => Task.CompletedTask; + options.OnBeforeSaveAsync = _ => Task.CompletedTask; options.OnProcessedAsync = _ => Task.CompletedTask; options.OnPrepareResponseAsync = _ => Task.CompletedTask; })