This is a migrated thread and some comments may be shown as answers.

default crop to unconstrained proportions

4 Answers 67 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 23 Apr 2012, 07:03 PM
Hello, 

How can I change the default setting of the Crop tool from Constrained Proportions to Unconstrained Proportions.

I see many threads about defining the size, ratio and disabling buttons for easy thumbnail creation, but I just need to change the default to Unconstrained. 

4 Answers, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 24 Apr 2012, 04:39 PM
Hello Brad,

You can easily modify the widget dialog UI from the client-side. You can check the following forum post for a similar request - http://www.telerik.com/community/forums/aspnet-ajax/image-editor/cropping.aspx.
Basically you could call the set_checked(false) to the constraint button of the crop box dialog. Here is a sample implementation:
function modifyCommand (editor, args)
{
    waitForCommand(editor, args.get_commandName(), function(widget) {
        widget._constraintBtn.set_checked(false);
    });
}
  
function waitForCommand(imageEditor, commandName, callback)
{
    var timer = setInterval(function()
    {
        var widget = imageEditor.get_currentToolWidget();
        if(widget && widget.get_name() == commandName)
        {
            clearInterval(timer);
            callback(widget);
        }
    }, 200);
}
where modifyCommand is an event handler of the OnClientCommandExecuted.

Hope this helps.

All the best,
Niko
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Brad
Top achievements
Rank 1
answered on 09 May 2012, 12:11 AM
Hello Niko,

I am unable to get this code to work on my site. Can you confirm that the code posted above works for you. Attached are screenshots of what happens for me.

The code modifies the widget and changes the Constrain Proportions button to a broken link. But, dragging and dropping the Crop Selection still constrains the proportions. If I click the Constrain Proportions button with the mouse until it is a broken link, then the Crop Selection operates properly.

Brad

0
Accepted
Niko
Telerik team
answered on 09 May 2012, 09:45 AM
Hello Brad,

Please, accept my apologies for the incomplete example that I was given you. There are two more things that should be done in order to the dialog to restrain the constraints on the crop box. Here is a more complete solution (for brevity I have skipped the declaration of the waitForCommand method):
function modifyCommand(editor, args)
{
    if(args.get_commandName() == "Crop")
        waitForCommand(editor, "Crop", function(widget) {
            widget._constraintBtn.set_checked(false);
            widget._setCropBoxRatio(null);
            widget._sizeRatio = null;
        });
}

Hope this helps.

Kind regards,
Niko
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Brad
Top achievements
Rank 1
answered on 09 May 2012, 10:24 PM
Thanks Niko, those extra statements worked.
Tags
ImageEditor
Asked by
Brad
Top achievements
Rank 1
Answers by
Niko
Telerik team
Brad
Top achievements
Rank 1
Share this question
or