Make WordPress Core

Ticket #11325: 11325.diff

File 11325.diff, 2.0 KB (added by solarissmoke, 15 years ago)
  • wp-admin/js/image-edit.dev.js

     
    11var imageEdit;
     2var imageEdit;
    23
    34(function($) {
    45imageEdit = {
     
    343344        },
    344345
    345346        setCropSelection : function(postid, c) {
    346                 var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128',
    347                         sizer = this.hold['sizer'];
    348                         min = min.split(':');
    349                         c = c || 0;
     347                var sel;
     348               
     349                c = c || 0;
    350350
    351351                if ( !c || ( c.width < 3 && c.height < 3 ) ) {
    352352                        this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
     
    357357                        return false;
    358358                }
    359359
    360                 if ( c.width < (min[0] * sizer) && c.height < (min[1] * sizer) ) {
    361                         this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
    362                         $('#imgedit-selection-' + postid).val('');
    363                         return false;
    364                 }
    365 
    366360                sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
    367361                this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1);
    368362                $('#imgedit-selection-' + postid).val( JSON.stringify(sel) );
     
    433427        crop : function (postid, nonce, t) {
    434428                var sel = $('#imgedit-selection-' + postid).val(),
    435429                        w = this.intval( $('#imgedit-sel-width-' + postid).val() ),
    436                         h = this.intval( $('#imgedit-sel-height-' + postid).val() );
     430                        h = this.intval( $('#imgedit-sel-height-' + postid).val() ),
     431                        min = $('#imgedit-minthumb-' + postid).val() || '128:128',
     432                        sizer = this.hold.sizer,
     433                       
     434                min = min.split(':');
    437435
    438436                if ( $(t).hasClass('disabled') || sel == '' )
    439437                        return false;
    440 
     438               
    441439                sel = JSON.parse(sel);
     440                if( sel.w < ( min[0] * sizer ) && sel.h < ( min[1] * sizer ) ) {
     441                        alert( 'The area you have selected for cropping is smaller than the default thumbnail size (' + min.join(':') + '). Please select a larger area.' );
     442                        return false;
     443                }
     444               
    442445                if ( sel.w > 0 && sel.h > 0 && w > 0 && h > 0 ) {
    443446                        sel['fw'] = w;
    444447                        sel['fh'] = h;