Ticket #27366: 27366.10.patch
File 27366.10.patch, 11.7 KB (added by , 11 years ago) |
---|
-
src/wp-admin/css/themes.css
1283 1283 .more-filters-container .filtering-by .tag { 1284 1284 background: #fff; 1285 1285 border: 1px solid #e5e5e5; 1286 -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04); 1286 1287 box-shadow: 0 1px 1px rgba(0,0,0,0.04); 1287 1288 font-size: 11px; 1288 1289 margin: 0 5px; -
src/wp-includes/css/media-views.css
1640 1640 } 1641 1641 1642 1642 .image-details .advanced-toggle { 1643 font-style: italic;1644 1643 color: #666; 1645 1644 text-decoration: none; 1646 margin: 20px;1647 1645 display: block; 1648 1646 } 1649 1647 … … 1663 1661 margin-top: 0; 1664 1662 } 1665 1663 1664 .image-details .embed-media-settings .size { 1665 margin-bottom: 4px; 1666 } 1667 1668 .image-details .custom-size span { 1669 display: block; 1670 } 1671 1672 .image-details .custom-size label { 1673 display: block; 1674 float: left; 1675 } 1676 1677 .image-details .custom-size span small { 1678 color: #999; 1679 font-size: inherit; 1680 } 1681 1682 .image-details .custom-size input { 1683 width: 5em; 1684 } 1685 1686 .image-details .custom-size .sep { 1687 float: left; 1688 margin: 26px 6px 0 6px; 1689 } 1690 1691 .image-details .custom-size::after { 1692 content: ''; 1693 display: table; 1694 clear: both; 1695 } 1696 1666 1697 .media-embed .thumbnail { 1667 1698 max-width: 100%; 1668 1699 max-height: 200px; … … 1724 1755 } 1725 1756 1726 1757 .image-details .embed-media-settings .setting input.link-to-custom, 1727 .image-details .embed-media-settings .link-target { 1758 .image-details .embed-media-settings .link-target, 1759 .image-details .embed-media-settings .custom-size { 1728 1760 margin-left: 27%; 1729 1761 width: 70%; 1730 1762 } … … 2003 2035 margin-left: 0; 2004 2036 } 2005 2037 2006 .image-details . link-target{2007 width: 100%;2038 .image-details .embed-media-settings .custom-size { 2039 margin-left: 20px; 2008 2040 } 2009 2041 2010 2042 .media-selection { -
src/wp-includes/js/media-models.js
369 369 this.on( 'change:size', this.updateSize, this ); 370 370 371 371 this.setLinkTypeFromUrl(); 372 373 this.set( 'aspectRatio', attributes.customWidth / attributes.customHeight ); 374 this.set( 'originalUrl', attributes.url ); 372 375 }, 373 376 374 377 bindAttachmentListeners: function() { … … 447 450 return; 448 451 } 449 452 453 if ( this.get( 'size' ) === 'custom' ) { 454 this.set( 'width', this.get( 'customWidth' ) ); 455 this.set( 'height', this.get( 'customHeight' ) ); 456 this.set( 'url', this.get( 'originalUrl' ) ); 457 return; 458 } 459 450 460 size = this.attachment.get( 'sizes' )[ this.get( 'size' ) ]; 451 461 452 462 if ( ! size ) { -
src/wp-includes/js/media-views.js
6059 6059 events: _.defaults( media.view.Settings.AttachmentDisplay.prototype.events, { 6060 6060 'click .edit-attachment': 'editAttachment', 6061 6061 'click .replace-attachment': 'replaceAttachment', 6062 'click .advanced-toggle': 'toggleAdvanced' 6062 '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 6067 } ), 6064 6068 initialize: function() { 6065 6069 // used in AttachmentDisplay.prototype.updateLinkTo … … 6066 6070 this.options.attachment = this.model.attachment; 6067 6071 this.listenTo( this.model, 'change:url', this.updateUrl ); 6068 6072 this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); 6073 this.listenTo( this.model, 'change:size', this.toggleCustomSize ); 6069 6074 media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments ); 6070 6075 }, 6071 6076 … … 6123 6128 } 6124 6129 }, 6125 6130 6131 toggleCustomSize: function() { 6132 if ( this.model.get( 'size' ) !== 'custom' ) { 6133 this.$( '.custom-size' ).addClass('hidden'); 6134 } else { 6135 this.$( '.custom-size' ).removeClass('hidden'); 6136 } 6137 }, 6138 6139 syncCustomSize: function( event ) { 6140 var dimension = $( event.target ).data('setting'), 6141 value; 6142 6143 if ( dimension === 'customWidth' ) { 6144 value = Math.round( 1 / this.model.get( 'aspectRatio' ) * $( event.target ).val() ); 6145 this.model.set( 'customHeight', value, { silent: true } ); 6146 this.$( '[data-setting="customHeight"]' ).val( value ); 6147 } else { 6148 value = Math.round( this.model.get( 'aspectRatio' ) * $( event.target ).val() ); 6149 this.$( '[data-setting="customWidth"]' ).val( value ); 6150 this.model.set( 'customWidth', value, { silent: true } ); 6151 } 6152 }, 6153 6126 6154 toggleAdvanced: function( event ) { 6127 6155 var $advanced = $( event.target ).closest( '.advanced' ); 6128 6156 event.preventDefault(); -
src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
123 123 url: false, 124 124 height: '', 125 125 width: '', 126 size: false, 126 customWidth: '', 127 customHeight: '', 128 size: 'custom', 127 129 caption: '', 128 130 alt: '', 129 131 align: 'none', … … 139 141 metadata.url = dom.getAttrib( imageNode, 'src' ); 140 142 metadata.alt = dom.getAttrib( imageNode, 'alt' ); 141 143 metadata.title = dom.getAttrib( imageNode, 'title' ); 142 143 144 width = dom.getAttrib( imageNode, 'width' ) || imageNode.width; 144 145 height = dom.getAttrib( imageNode, 'height' ) || imageNode.height; 145 146 146 metadata.width = parseInt( width, 10 ); 147 147 metadata.height = parseInt( height, 10 ); 148 metadata.customWidth = metadata.width; 149 metadata.customHeight = metadata.height; 148 150 149 151 classes = tinymce.explode( imageNode.className, ' ' ); 150 152 extraClasses = []; … … 199 201 return metadata; 200 202 } 201 203 204 function hasTextContent( node ) { 205 return node && !! ( node.textContent || node.innerText ); 206 } 207 202 208 function updateImage( imageNode, imageData ) { 203 var classes, className, width, node, html, parent, wrap,204 captionNode, dd, dl, id, attrs, linkAttrs, 209 var classes, className, node, html, parent, wrap, linkNode, 210 captionNode, dd, dl, id, attrs, linkAttrs, width, height, 205 211 dom = editor.dom; 206 212 207 213 classes = tinymce.explode( imageData.extraClasses, ' ' ); … … 216 222 217 223 if ( imageData.attachment_id ) { 218 224 classes.push( 'wp-image-' + imageData.attachment_id ); 219 if ( imageData.size ) {225 if ( imageData.size && imageData.size !== 'custom' ) { 220 226 classes.push( 'size-' + imageData.size ); 221 227 } 222 228 } 223 229 230 width = imageData.width; 231 height = imageData.height; 232 233 if ( imageData.size === 'custom' ) { 234 width = imageData.customWidth; 235 height = imageData.customHeight; 236 } 237 224 238 attrs = { 225 239 src: imageData.url, 226 width: imageData.width || null,227 height: imageData.height || null,240 width: width || null, 241 height: height || null, 228 242 alt: imageData.alt, 229 243 title: imageData.title || null, 230 244 'class': classes.join( ' ' ) || null … … 239 253 'class': imageData.linkClassName || null 240 254 }; 241 255 242 if ( imageNode.parentNode.nodeName === 'A' ) { 256 if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { 257 // Update or remove an existing link wrapped around the image 243 258 if ( imageData.linkUrl ) { 244 259 dom.setAttribs( imageNode.parentNode, linkAttrs ); 245 260 } else { … … 246 261 dom.remove( imageNode.parentNode, true ); 247 262 } 248 263 } else if ( imageData.linkUrl ) { 249 html = dom.createHTML( 'a', linkAttrs, dom.getOuterHTML( imageNode ) ); 250 dom.outerHTML( imageNode, html ); 264 if ( linkNode = dom.getParent( imageNode, 'a' ) ) { 265 // The image is inside a link together with other nodes, 266 // or is nested in another node, move it out 267 dom.insertAfter( imageNode, linkNode ); 268 } 269 270 // Add link wrapped around the image 271 linkNode = dom.create( 'a', linkAttrs ); 272 imageNode.parentNode.insertBefore( linkNode, imageNode ); 273 linkNode.appendChild( imageNode ); 251 274 } 252 275 253 276 captionNode = editor.dom.getParent( imageNode, '.mceTemp' ); 254 277 255 if ( imageNode.parentNode .nodeName === 'A') {278 if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { 256 279 node = imageNode.parentNode; 257 280 } else { 258 281 node = imageNode; … … 259 282 } 260 283 261 284 if ( imageData.caption ) { 262 width = parseInt( imageData.width, 10 ); 285 263 286 id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null; 264 className = 'wp-caption align' + imageData.align;287 className = 'wp-caption align' + ( imageData.align || 'none' ); 265 288 266 289 if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) { 290 width = parseInt( width, 10 ); 267 291 width += 10; 268 292 } 269 293 … … 312 336 } 313 337 314 338 editor.nodeChanged(); 315 // refresh the toolbar339 // Refresh the toolbar 316 340 addToolbar( imageNode ); 317 341 } 318 342 … … 324 348 return; 325 349 } 326 350 327 editor.undoManager.add();328 329 351 frame = wp.media({ 330 352 frame: 'image', 331 353 state: 'image-details', … … 333 355 } ); 334 356 335 357 callback = function( imageData ) { 336 updateImage( img, imageData );337 358 editor.focus(); 359 editor.undoManager.transact( function() { 360 updateImage( img, imageData ); 361 } ); 338 362 frame.detach(); 339 363 }; 340 364 -
src/wp-includes/media-template.php
689 689 690 690 <# if ( data.attachment ) { #> 691 691 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> 692 <label class="setting ">692 <label class="setting size"> 693 693 <span><?php _e('Size'); ?></span> 694 694 <select class="size" name="size" 695 695 data-setting="size" … … 705 705 'full' => __('Full Size'), 706 706 ) ); 707 707 708 708 709 foreach ( $sizes as $value => $name ) : ?> 709 710 <# 710 711 var size = data.sizes['<?php echo esc_js( $value ); ?>']; 711 712 if ( size ) { #> 712 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>713 <option value="<?php echo esc_attr( $value ); ?>"> 713 714 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} 714 715 </option> 715 716 <# } #> 716 717 <?php endforeach; ?> 718 <option value="<?php echo esc_attr( 'custom' ); ?>"> 719 <?php _e( 'Custom Size' ); ?> 720 </option> 717 721 </select> 718 722 </label> 719 723 <# } #> 724 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> 725 <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> 726 </div> 720 727 <# } #> 721 728 722 729 <div class="setting link-to"> … … 744 751 <input type="text" class="link-to-custom" data-setting="linkUrl" /> 745 752 </div> 746 753 <div class="advanced"> 747 < a class="advanced-toggle" href="#"><?php _e('Show advanced options'); ?></a>754 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3> 748 755 <div class="hidden"> 749 756 <label class="setting title-text"> 750 757 <span><?php _e('Image Title Attribute'); ?></span>