Search code examples
javascriptselectionjcrop

JCrop: Adding text to selection area - possible?


I'm intending to use JCrop for a standard image upload feature. Everything is all right so far, it works great. BUT: there is a minimum image size required, so instead of letting the user do his cropping and then stop him with an error message when he tries to ulpoad, I'd like to insert a continuous (or at least after selecting) info-text about the current selection size. So, here's my question: can you add text to the jcrop selection area? Or would I have to create something myself?

Thanks for your input!


Solution

  • The short answer is no you can't add text to the selection area. You could, of course make additions to the jcrop script and add such functionality (which I think would be a cool addition).

    I had a similar need (ie. to inform user that it was too small) and did it in a separate area based on the selection size. Something along the lines of:

    $("#myDiv").Jcrop({onChange: checkSelection},function(){jcrop_api = this;));
    
    function checkSelection(c){
      if (c.x2 - c.x < minWidth)
        ...