Created
December 19, 2017 13:39
-
-
Save sandeepvpote/5ae257440eab2a6a0f06da4be0f58548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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