New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Custom Crop Settings

One of the most common scenarios connected with the cropping functionality of the ImageEditor is setting the initial size or changing the ratio constraints of the crop box. In the example bellow you will see a way to modify the Crop command in the ImageEditor’s ClientCommandExecuted event handler by setting:

  • the initial width and height of the crop box;

  • the ratio between the crop box’s width and height.

How to Customize a Built-in Command

Before applying the desired modifications to the Crop command (or another one), you have to make sure that the Crop dialog has been fully loaded. This can be done by setting a little interval so you can check the widget availability periodically:

<telerik:RadImageEditor RenderMode="Lightweight" ID="RadImageEditor1" runat="server" ImageUrl="image.jpg"
<script type="text/javascript">
    function modifyCommand(imageEditor, args) {
        if (args.get_commandName() == "Crop") {
            waitForCommand(imageEditor, args.get_commandName(), function (widget) {
                var width = 150;
                var height = 200;
                var ratio = width / height;

                //stop the aspect ratio constraint
                //widget._sizeRatio = null;

                widget._sizeRatio = ratio;

    function waitForCommand(imageEditor, commandName, callback) {
        var timer = setInterval(function () {
            var widget = imageEditor.get_currentToolWidget();
            if (widget && widget.get_name() == commandName) {
        }, 100);

See Also

In this article