Make WordPress Core

Ticket #27366: 27366-11.patch

File 27366-11.patch, 3.5 KB (added by gcorne, 11 years ago)
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index 377f020..6a01aa6 100644
     
    60606060                        'click .edit-attachment': 'editAttachment',
    60616061                        'click .replace-attachment': 'replaceAttachment',
    60626062                        'click .advanced-toggle': 'toggleAdvanced',
    6063                         'change [data-setting="customWidth"]': 'syncCustomSize',
    6064                         'change [data-setting="customHeight"]': 'syncCustomSize',
    6065                         'keyup [data-setting="customWidth"]': 'syncCustomSize',
    6066                         'keyup [data-setting="customHeight"]': 'syncCustomSize'
     6063                        'change [data-setting="customWidth"]': 'onCustomSize',
     6064                        'change [data-setting="customHeight"]': 'onCustomSize',
     6065                        'keyup [data-setting="customWidth"]': 'onCustomSize',
     6066                        'keyup [data-setting="customHeight"]': 'onCustomSize'
    60676067                } ),
    60686068                initialize: function() {
    60696069                        // used in AttachmentDisplay.prototype.updateLinkTo
     
    61366136                        }
    61376137                },
    61386138
    6139                 syncCustomSize: function( event ) {
     6139                onCustomSize: function( event ) {
    61406140                        var dimension = $( event.target ).data('setting'),
     6141                                num = $( event.target ).val(),
    61416142                                value;
    61426143
     6144                        // Ignore bogus input
     6145                        if ( ! /^\d+/.test( num ) || parseInt( num, 10 ) < 1 ) {
     6146                                event.preventDefault();
     6147                                return;
     6148                        }
     6149
    61436150                        if ( dimension === 'customWidth' ) {
    6144                                 value = Math.round( 1 / this.model.get( 'aspectRatio' ) * $( event.target ).val() );
     6151                                value = Math.round( 1 / this.model.get( 'aspectRatio' ) * num );
    61456152                                this.model.set( 'customHeight', value, { silent: true } );
    61466153                                this.$( '[data-setting="customHeight"]' ).val( value );
    61476154                        } else {
    6148                                 value = Math.round( this.model.get( 'aspectRatio' ) * $( event.target ).val() );
     6155                                value = Math.round( this.model.get( 'aspectRatio' ) * num );
     6156                                this.model.set( 'customWidth', value, { silent: true  } );
    61496157                                this.$( '[data-setting="customWidth"]' ).val( value );
    6150                                 this.model.set( 'customWidth', value, { silent: true } );
     6158
    61516159                        }
    61526160                },
    61536161
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    diff --git src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
    index b7dcbae..9148410 100644
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    114114        }
    115115
    116116        function extractImageData( imageNode ) {
    117                 var classes, extraClasses, metadata, captionBlock, caption, link, width, height,
     117                var classes, extraClasses, metadata, captionBlock, caption, link, width,
    118118                        dom = editor.dom;
    119119
    120120                // default attributes
    121121                metadata = {
    122122                        attachment_id: false,
    123                         url: false,
    124                         height: '',
    125                         width: '',
    126                         customWidth: '',
    127                         customHeight: '',
    128123                        size: 'custom',
    129124                        caption: '',
    130                         alt: '',
    131125                        align: 'none',
    132126                        extraClasses: '',
    133127                        link: false,
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    141135                metadata.url = dom.getAttrib( imageNode, 'src' );
    142136                metadata.alt = dom.getAttrib( imageNode, 'alt' );
    143137                metadata.title = dom.getAttrib( imageNode, 'title' );
    144                 width = dom.getAttrib( imageNode, 'width' ) || imageNode.width;
    145                 height = dom.getAttrib( imageNode, 'height' ) || imageNode.height;
    146                 metadata.width = parseInt( width, 10 );
    147                 metadata.height = parseInt( height, 10 );
    148                 metadata.customWidth = metadata.width;
    149                 metadata.customHeight = metadata.height;
     138                metadata.customWidth = metadata.width = width = imageNode.width;
     139                metadata.customHeight = metadata.height = imageNode.height;
    150140
    151141                classes = tinymce.explode( imageNode.className, ' ' );
    152142                extraClasses = [];