Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all.
Can we intercept image request and return a manipulated image in Umbraco 9 with ImageSharp IRequestParser?
In Umbraco 8 we could use the ImageProcessingModule.ValidatingRequest and the ImageProcessingModule.OnPostProcessing.
ImageProcessingModule.ValidatingRequest
ImageProcessingModule.OnPostProcessing
Can we do something similar in Umbraco 9?
We found a solution.
We can hook into the process this way.
public class CustomWebProcessor : IImageWebProcessor { private const string QueryStringName = "custom"; public IEnumerable<string> Commands => new[] { QueryStringName }; public FormattedImage Process(FormattedImage image, ILogger logger, IDictionary<string, string> commands, CommandParser parser, CultureInfo culture) { var QueryStringValue = parser.ParseValue<int>(commands.GetValueOrDefault(QueryStringName), culture); image.Image.Mutate(ctx => ctx.Brightness(QueryStringValue)); return image; } }
and then make a static helper to add it to the builder.
public static IUmbracoBuilder AddImageWebProcessor(this IUmbracoBuilder builder) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IImageWebProcessor, CustomWebProcessor>()); return builder; }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
is there a way to Post Processing images on request
Hi all.
Can we intercept image request and return a manipulated image in Umbraco 9 with ImageSharp IRequestParser?
In Umbraco 8 we could use the
ImageProcessingModule.ValidatingRequest
and theImageProcessingModule.OnPostProcessing
.Can we do something similar in Umbraco 9?
We found a solution.
We can hook into the process this way.
and then make a static helper to add it to the builder.
is working on a reply...