Allow configuration of all ImageSharp options#12614
Allow configuration of all ImageSharp options#12614matthewcare wants to merge 3 commits intoumbraco:v10/contribfrom
Conversation
Add missing settings to the imagine settings, and add a new interface to be able to override / extend the methods
Allow hmac to be null
|
Hi there @matthewcare, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Remove access modifier mistakenly added to interface
|
Hi @matthewcare, although this does look really well written, we don't want to tightly couple with ImageSharp even more than we do now. Plus you can already add public class ConfigureImageSharpMiddlewareOptionsComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
=> builder.Services.Configure<ImageSharpMiddlewareOptions>(options =>
{
// Capture existing task to not overwrite it
var onParseCommandsAsync = options.OnParseCommandsAsync;
options.OnParseCommandsAsync = async context =>
{
// Custom logic before
await onParseCommandsAsync(context);
// Custom logic after
};
});
} |
|
Hi @ronaldbarendse I understand if this isn't desired though, feel free to close. |
All the related interfaces currently don't use ImageSharp specific types, which this PR does introduce with |
Prerequisites
This PR updates the
ImageSharpMiddlewareOptionsconfiguration so that all of the options are configurable.Registering your own imaging options allows you to override or extend upon the default methods.
To test, create a new implementation of
IAdditionalImagingOptionsIn this example I'm verifying that the requesting browser supports webp, and remove the command if it doesn't. I extend the default options so that they can also be executed.
In your startup class you set the default options like this
Remember, when you're testing, your image might be cached.