How to make ImageSharp.Web intercept all image requests including these without querystring #315
-
Hey, I am working on upgrading a solution which was using ImageProcessor.Wev to ImageSharp.Web. I have a requirement to remove the metadata of all images on my website. I found how to remove the metadata, but I want also to handle the images which URLs don't contain query string. In ImageProcessorWeb package there was a setting called interceptAllRequests (https://imageprocessor.org/imageprocessor-web/configuration/) How can I accomplish this behavior now with ImageSharp.Web? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
It's a bit different with ImageSharp.Web Whether all requests should be captured it the responsibility of the individual IImageProvider implementations. For the services.AddImageSharp()
.Configure<PhysicalFileSystemProviderOptions>(options =>
{
options.ProcessingBehavior = ProcessingBehavior.All;
}); |
Beta Was this translation helpful? Give feedback.
-
You likely want to use post configuration. I’ve no idea what the Umbraco configuration pipeline is. It’s very custom |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply again! Excuse me for bothering with Umbraco which is not relevant for this ticket. I found out why the metadata is not removed for images with no query string. In ImageSharpMiddleware the "commands" are parsed from the query string and even if there are some checks which let the processing happen when ProcessingBehavior.All almost at the end there is this check
I end up in the if statement and the OnBeforeSaveAsync is not executed, so the metadata is not removed. I am wondering now f you have a suggestion on how to work around that. Now I remember the for ImageProcessor.Web I had included the package source code and modified the logic, but I would like not to do that here. |
Beta Was this translation helpful? Give feedback.
-
I just had a thought… |
Beta Was this translation helpful? Give feedback.
Thanks for your reply again! Excuse me for bothering with Umbraco which is not relevant for this ticket.
I found out why the metadata is not removed for images with no query string. In ImageSharpMiddleware the "commands" are parsed from the query string and even if there are some checks which let the processing happen when ProcessingBehavior.All almost at the end there is this check