diff --git src/wp-includes/css/media-views.css src/wp-includes/css/media-views.css
index 7ee5d1e..8a240af 100644
|
|
|
|
| 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 | } |
diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
index 19e9021..9aa8031 100644
|
|
|
window.wp = window.wp || {}; |
| 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() { |
| … |
… |
window.wp = window.wp || {}; |
| 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 ) { |
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
index def3993..377f020 100644
|
|
|
|
| 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(); |
diff --git src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
index a5af171..9ca0b19 100644
|
|
|
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 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', |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 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 = []; |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 200 | 202 | } |
| 201 | 203 | |
| 202 | 204 | function updateImage( imageNode, imageData ) { |
| 203 | | var classes, className, width, node, html, parent, wrap, |
| 204 | | captionNode, dd, dl, id, attrs, linkAttrs, |
| | 205 | var classes, className, node, html, parent, wrap, |
| | 206 | captionNode, dd, dl, id, attrs, linkAttrs, width, height, |
| 205 | 207 | dom = editor.dom; |
| 206 | 208 | |
| 207 | 209 | classes = tinymce.explode( imageData.extraClasses, ' ' ); |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 216 | 218 | |
| 217 | 219 | if ( imageData.attachment_id ) { |
| 218 | 220 | classes.push( 'wp-image-' + imageData.attachment_id ); |
| 219 | | if ( imageData.size ) { |
| | 221 | if ( imageData.size && imageData.size !== 'custom' ) { |
| 220 | 222 | classes.push( 'size-' + imageData.size ); |
| 221 | 223 | } |
| 222 | 224 | } |
| 223 | 225 | |
| | 226 | width = imageData.width; |
| | 227 | height = imageData.height; |
| | 228 | |
| | 229 | if ( imageData.size === 'custom' ) { |
| | 230 | width = imageData.customWidth; |
| | 231 | height = imageData.customHeight; |
| | 232 | } |
| | 233 | |
| 224 | 234 | attrs = { |
| 225 | 235 | src: imageData.url, |
| 226 | | width: imageData.width || null, |
| 227 | | height: imageData.height || null, |
| | 236 | width: width || null, |
| | 237 | height: height || null, |
| 228 | 238 | alt: imageData.alt, |
| 229 | 239 | title: imageData.title || null, |
| 230 | 240 | 'class': classes.join( ' ' ) || null |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 239 | 249 | 'class': imageData.linkClassName || null |
| 240 | 250 | }; |
| 241 | 251 | |
| 242 | | if ( imageNode.parentNode.nodeName === 'A' ) { |
| | 252 | if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { |
| 243 | 253 | if ( imageData.linkUrl ) { |
| 244 | 254 | dom.setAttribs( imageNode.parentNode, linkAttrs ); |
| 245 | 255 | } else { |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 247 | 257 | } |
| 248 | 258 | } else if ( imageData.linkUrl ) { |
| 249 | 259 | html = dom.createHTML( 'a', linkAttrs, dom.getOuterHTML( imageNode ) ); |
| 250 | | dom.outerHTML( imageNode, html ); |
| | 260 | dom.setOuterHTML( imageNode, html ); |
| | 261 | // Grab the updated image node |
| | 262 | imageNode = dom.select( 'img[data-wp-imgselect]' )[0]; |
| 251 | 263 | } |
| 252 | 264 | |
| 253 | 265 | captionNode = editor.dom.getParent( imageNode, '.mceTemp' ); |
| 254 | 266 | |
| 255 | | if ( imageNode.parentNode.nodeName === 'A' ) { |
| | 267 | if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { |
| 256 | 268 | node = imageNode.parentNode; |
| 257 | 269 | } else { |
| 258 | 270 | node = imageNode; |
| 259 | 271 | } |
| 260 | 272 | |
| 261 | 273 | if ( imageData.caption ) { |
| 262 | | width = parseInt( imageData.width, 10 ); |
| | 274 | |
| 263 | 275 | id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null; |
| 264 | 276 | className = 'wp-caption align' + imageData.align; |
| 265 | 277 | |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 312 | 324 | } |
| 313 | 325 | |
| 314 | 326 | editor.nodeChanged(); |
| 315 | | // refresh the toolbar |
| | 327 | // Refresh the toolbar |
| 316 | 328 | addToolbar( imageNode ); |
| 317 | 329 | } |
| 318 | 330 | |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 324 | 336 | return; |
| 325 | 337 | } |
| 326 | 338 | |
| 327 | | editor.undoManager.add(); |
| 328 | | |
| 329 | 339 | frame = wp.media({ |
| 330 | 340 | frame: 'image', |
| 331 | 341 | state: 'image-details', |
| … |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
| 333 | 343 | } ); |
| 334 | 344 | |
| 335 | 345 | callback = function( imageData ) { |
| 336 | | updateImage( img, imageData ); |
| 337 | 346 | editor.focus(); |
| | 347 | editor.undoManager.transact( function() { |
| | 348 | updateImage( img, imageData ); |
| | 349 | } ); |
| 338 | 350 | frame.detach(); |
| 339 | 351 | }; |
| 340 | 352 | |
diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php
index aa2e11f..fc11870 100644
|
|
|
function wp_print_media_templates() { |
| 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" |
| … |
… |
function wp_print_media_templates() { |
| 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"> |
| … |
… |
function wp_print_media_templates() { |
| 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> |