This component checks all images uploaded to the media section and restricts the size of the pixel image. This stops clients uploading rediculous size images into the media section.
- Copy the .cs files into your project
- In startup.cs add
.AddNotificationHandler<MediaSavedNotification, ImageMaxSizeHandler>()
inConfigureServices(){}
. Add it right before `.Build(). For Example:services.AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddComposers() .AddNotificationHandler<MediaSavedNotification, ImageMaxSizeHandler>() .Build();
- By default it will restrict images to 1920px wide, however you can add the following configuration to appsettings.json to configure the maximum sizes. The 0 below defaults to any height.
"DM": { "Imaging": { "MaxWidth": 1500, "MaxHeight": 0 } }