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
I would like to restrict CMS users from adding large files to the Media library. Is there an extension i could write to validate files uploaded?
If you want exclude specific file extensions to be uploaded to the media library then you can add the file extension(s) to the Disallow section in the umbracoSettings.config.
<!-- These file types will not be allowed to be uploaded via the upload control for media and content -->
Hope this helps,
In order to cancel out large files, you could go about doing a class that derive from ApplicationEventHandler and hook up to MediaService.Saving event:
public class AppEventHandler : ApplicationEventHandler
const int MAX_SIZE = 100000;
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
MediaService.Saving += (sender, e) =>
foreach (var entity in e.SavedEntities)
var property = entity?.Properties?.First(p => p.Alias.InvariantEquals("umbracobytes"));
if (property != null)
var size = Convert.ToInt32(property.Value);
if (size > MAX_SIZE)
e.Cancel = true; // todo: explain cancel in notification
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted