Make WordPress Core

Ticket #21785: 21785-doCrop-move.diff

File 21785-doCrop-move.diff, 1.7 KB (added by ehg, 11 years ago)
  • src/wp-includes/js/media-models.js

    diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
    index 2e406d7..0405b56 100644
    window.wp = window.wp || {}; 
    320320                        }, data ) ).done( function( resp, status, xhr ) {
    321321                                model.set( model.parse( resp, xhr ), options );
    322322                        });
     323                },
     324                crop: function() {
     325                        return wp.ajax.post( 'custom-header-crop', {
     326                                nonce: this.get('nonces').edit,
     327                                id: this.get('id'),
     328                                cropDetails: this.get('cropDetails')
     329                        } );
    323330                }
    324331        }, {
    325332                /**
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index 4c2114c..56684c4 100644
     
    13671367
    13681368                                                click: function() {
    13691369                                                        var self = this,
    1370                                                                 selection = this.controller.state().get('selection').first();
     1370                                                                selection = new media.model.Attachment(this.controller.state().get('selection').first().attributes);
    13711371
    13721372                                                        selection.set({cropDetails: this.controller.state().imgSelect.getSelection()});
    13731373
    13741374                                                        this.$el.text(l10n.cropping);
    13751375                                                        this.$el.attr('disabled', true);
    1376                                                         this.controller.state().doCrop( selection ).done( function( croppedImage ) {
     1376                                                        selection.crop().done( function( croppedImage ) {
    13771377                                                                self.controller.trigger('cropped', croppedImage );
    13781378                                                                self.controller.close();
    13791379                                                        });
     
    14001400                        }
    14011401
    14021402                        this.frame.toolbar.set( new wp.media.view.Toolbar(toolbarOptions) );
    1403                 },
    1404 
    1405                 doCrop: function( attachment ) {
    1406                         return wp.ajax.post( 'custom-header-crop', {
    1407                                 nonce: attachment.get('nonces').edit,
    1408                                 id: attachment.get('id'),
    1409                                 cropDetails: attachment.get('cropDetails')
    1410                         } );
    14111403                }
    14121404        });
    14131405