Can I set the Min & Max Cropping Width & Height

4 posts, 0 answers
  1. Pierre
    Pierre avatar
    4 posts
    Member since:
    Feb 2011

    Posted 23 Jan 2013 Link to this post

    Hi,

    Is it possible to set the minimum + maximum width and height of the crop box? I would like the user to be able to manually resize the crop box, but not bigger than 480px for the width or height. I am not concerned about aspect ratio.

    Thanks in advance.

    Kind regards,
    Pierre
  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 28 Jan 2013 Link to this post

    Hi Pierre,

    The desired functionality is not among the ImageEditor's built-in features, but you could achieve it by modifying the ImageEditor's Crop dialog. In order to do it you will need to:
     - Register the external dialogs of the ImageEditor - detailed information on how to do it is available here.
     - Modify the _setCropBoxConstraints() function of the Crop dialog in the following way:
    _setCropBoxConstraints: function (bounds) {
        var image = this._imageEditor.getEditableImage();
        var zoomLevel = image.get_zoomLevel() / 100;
        bounds = new Sys.UI.Bounds(0, 0, parseInt(480 * zoomLevel), parseInt(480 * zoomLevel));
     
        this._cropBox.set_constraints(bounds || new Sys.UI.Bounds(0, 0, parseInt(image.get_width() * zoomLevel), parseInt(image.get_height() * zoomLevel)));
    }

    I hope this information was helpful for you.

    All the best,
    Vesi
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Martin Roussel
    Martin Roussel avatar
    246 posts
    Member since:
    Jan 2010

    Posted 05 Dec 2013 Link to this post

    Hi,

    im trying to lock permanently the Crop size to 33px by 33px. Can you please show how to edit the ascx file to do so? I can fix the numbers in the textboxes but the crop area seems to stay the default size.

    UPDATE: I figured a workaround so please ignore my previous question. My next issue is now I want to add some codebehind to the custom Crop.ascx to add some logic on control load, but im always getting this error when click the crop button:

    Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Could not load type '_Crop'. Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1…:15

     Is this supposed to work?

    my ascx Control tag definition:
    <%@ Control Language="C#" AutoEventWireup="True" CodeBehind="Crop.ascx.cs" Inherits="_Crop" %>

    my ascx.cs code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.ObjectModel;
     
        public partial class _Crop : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                
            }
        }


    TIA
  5. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 10 Dec 2013 Link to this post

    Hi Martin,

    I am glad that you have managed to find a workaround for the first issue.

    Regarding the code behind for the Crop dialog - the dialog itself has its Server-side functionality which doesn't have to be overriden. In order to add your own Server logic, you will need to create a custom user control, registered in the Crop.ascx file. Please, refer this KB for where the described approach is used: Displaying single upload control in the FileBrowser Upload manager

    Regards,
    Veselina Raykova
    Telerik
    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 the blog feed now.
Back to Top