Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Sitecore;
using Sitecore.Exceptions;
using Sitecore.Pipelines.Attach;
using System;
namespace MyProject.MediaUpload.Pipelines.Attach
{
public class ImageCheckSize
{
public void Process(AttachArgs args)
{
if (!ImageSettings.IsRestrictedExtension(args.File.FileName))
return;
if (args.MediaItem.FileBased || args.File.InputStream.Length <= ImageSettings.MaxImageSizeInDatabase)
return;
string errorMessage = "Custom Message"; //Change this to have a custom message
HttpContext.Current.Response.Write(
"<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowAlert(\"" +
errorMessage + "\")')</script></head><body>Done</body></html>");
args.AbortPipeline();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.