public ImagingSettingsWindow(ImagingSettings s) { isp = new ImagingSettingsViewModel(s); DataContext = isp;//bindeljuk a viewmodelt a viewhoz InitializeComponent(); //DataContext = isp;//bindeljuk a viewmodelt a viewhoz }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurePhysicalFileSystemCacheOptions" /> class. /// </summary> /// <param name="imagingSettings">The Umbraco imaging settings.</param> /// <param name="hostEnvironment">The host environment.</param> public ConfigurePhysicalFileSystemCacheOptions( IOptions <ImagingSettings> imagingSettings, IHostEnvironment hostEnvironment) { _imagingSettings = imagingSettings.Value; _hostEnvironment = hostEnvironment; }
/// <summary> /// Adds Image Sharp with Umbraco settings /// </summary> public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder builder) { ImagingSettings imagingSettings = builder.Config.GetSection(Cms.Core.Constants.Configuration.ConfigImaging) .Get <ImagingSettings>() ?? new ImagingSettings(); builder.Services.AddImageSharp(options => { // options.Configuration is set using ImageSharpConfigurationOptions below options.BrowserMaxAge = imagingSettings.Cache.BrowserMaxAge; options.CacheMaxAge = imagingSettings.Cache.CacheMaxAge; options.CachedNameLength = imagingSettings.Cache.CachedNameLength; // Use configurable maximum width and height (overwrite ImageSharps default) options.OnParseCommandsAsync = context => { if (context.Commands.Count == 0) { return(Task.CompletedTask); } uint width = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), context.Culture); uint height = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture); if (width > imagingSettings.Resize.MaxWidth || height > imagingSettings.Resize.MaxHeight) { context.Commands.Remove(ResizeWebProcessor.Width); context.Commands.Remove(ResizeWebProcessor.Height); } return(Task.CompletedTask); }; options.OnBeforeSaveAsync = _ => Task.CompletedTask; options.OnProcessedAsync = _ => Task.CompletedTask; options.OnPrepareResponseAsync = context => { // Change Cache-Control header when cache buster value is present if (context.Request.Query.ContainsKey("rnd")) { var headers = context.Response.GetTypedHeaders(); var cacheControl = headers.CacheControl; cacheControl.MustRevalidate = false; cacheControl.Extensions.Add(new NameValueHeaderValue("immutable")); headers.CacheControl = cacheControl; } return(Task.CompletedTask); }; }) .Configure <PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder)) .AddProcessor <CropWebProcessor>(); // Configure middleware to use the registered/shared ImageSharp configuration builder.Services.AddTransient <IConfigureOptions <ImageSharpMiddlewareOptions>, ImageSharpConfigurationOptions>(); return(builder.Services); }
/// <summary> /// Adds Image Sharp with Umbraco settings /// </summary> public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder builder) { ImagingSettings imagingSettings = builder.Config.GetSection(Cms.Core.Constants.Configuration.ConfigImaging) .Get <ImagingSettings>() ?? new ImagingSettings(); builder.Services.AddImageSharp(options => { // The configuration is set using ImageSharpConfigurationOptions options.BrowserMaxAge = imagingSettings.Cache.BrowserMaxAge; options.CacheMaxAge = imagingSettings.Cache.CacheMaxAge; options.CachedNameLength = imagingSettings.Cache.CachedNameLength; // Use configurable maximum width and height (overwrite ImageSharps default) options.OnParseCommandsAsync = context => { if (context.Commands.Count == 0) { return(Task.CompletedTask); } uint width = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), context.Culture); uint height = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture); if (width > imagingSettings.Resize.MaxWidth || height > imagingSettings.Resize.MaxHeight) { context.Commands.Remove(ResizeWebProcessor.Width); context.Commands.Remove(ResizeWebProcessor.Height); } return(Task.CompletedTask); }; }) .Configure <PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder)) // We need to add CropWebProcessor before ResizeWebProcessor (until https://github.com/SixLabors/ImageSharp.Web/issues/182 is fixed) .RemoveProcessor <ResizeWebProcessor>() .RemoveProcessor <FormatWebProcessor>() .RemoveProcessor <BackgroundColorWebProcessor>() .RemoveProcessor <JpegQualityWebProcessor>() .AddProcessor <CropWebProcessor>() .AddProcessor <ResizeWebProcessor>() .AddProcessor <FormatWebProcessor>() .AddProcessor <BackgroundColorWebProcessor>() .AddProcessor <JpegQualityWebProcessor>(); builder.Services.AddTransient <IConfigureOptions <ImageSharpMiddlewareOptions>, ImageSharpConfigurationOptions>(); return(builder.Services); }
public ImagingSettingsViewModel(ImagingSettings s) { _s = s; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigureImageSharpMiddlewareOptions" /> class. /// </summary> /// <param name="configuration">The ImageSharp configuration.</param> /// <param name="imagingSettings">The Umbraco imaging settings.</param> public ConfigureImageSharpMiddlewareOptions(Configuration configuration, IOptions <ImagingSettings> imagingSettings) { _configuration = configuration; _imagingSettings = imagingSettings.Value; }