Ticket #27366: 27366-02.patch
File 27366-02.patch, 19.3 KB (added by , 11 years ago) |
---|
-
src/wp-includes/css/media-views.css
diff --git src/wp-includes/css/media-views.css src/wp-includes/css/media-views.css index f3e03ff..b83fdf2 100644
1462 1462 padding: 16px; 1463 1463 } 1464 1464 1465 .media-frame .imgedit-wrap table { 1466 width: 100%; 1467 } 1468 1465 1469 .media-frame .imgedit-wrap table td { 1466 1470 vertical-align: top; 1467 1471 padding-top: 0; … … 1513 1517 overflow: auto; 1514 1518 } 1515 1519 1520 .image-details .media-modal { 1521 left: 140px; 1522 right: 140px; 1523 } 1524 1525 .image-details .media-frame-menu { 1526 display: none; 1527 } 1528 1529 .image-details .media-frame-title, 1530 .image-details .media-frame-content, 1531 .image-details .media-frame-router { 1532 left: 0; 1533 } 1534 1516 1535 .image-details .embed-media-settings { 1517 1536 top: 0; 1537 overflow: visible; 1538 } 1539 1540 .image-details .column-settings { 1541 width: 44%; 1542 float: left; 1543 margin-right: 20px; 1544 } 1545 1546 .image-details .column-image { 1547 width: 53%; 1548 float: left; 1549 } 1550 1551 .image-details .column-image:after { 1552 content: ''; 1553 display: table; 1554 clear: both; 1518 1555 } 1519 1556 1557 .image-details .image img { 1558 max-width: 100%; 1559 max-height: 500px; 1560 } 1561 1562 1520 1563 .media-embed .thumbnail { 1521 1564 max-width: 100%; 1522 1565 max-height: 200px; … … 1529 1572 display: block; 1530 1573 } 1531 1574 1532 .media-embed .edit-attachment {1533 margin-left: 10px;1534 }1535 1536 1575 .media-embed .thumbnail:after { 1537 1576 content: ''; 1538 1577 display: block; … … 1554 1593 clear: both; 1555 1594 } 1556 1595 1557 .media-embed .setting .hidden { 1596 .image-details .setting { 1597 float: none; 1598 } 1599 1600 .image-details .actions { 1601 margin: 10px 0; 1602 } 1603 1604 .media-embed .setting input[type="text"], 1605 .media-embed .setting textarea { 1606 display: block; 1607 width: 100%; 1608 max-width: 400px; 1609 margin: 1px 0; 1610 } 1611 1612 .image-details .setting input[type="text"], 1613 .image-details .setting textarea { 1614 max-width: inherit; 1615 } 1616 1617 .media-embed .setting input.hidden { 1558 1618 display: none; 1559 1619 } 1560 1620 … … 1570 1630 margin: 2px 0; 1571 1631 } 1572 1632 1573 .media-embed .setting input[type="text"], 1574 .media-embed .setting textarea { 1575 display: block; 1576 width: 100%; 1577 max-width: 400px; 1578 margin: 1px 0; 1633 .media-embed-sidebar { 1634 position: absolute; 1635 top: 0; 1636 left: 440px; 1637 } 1638 1639 .advanced, 1640 .link-settings { 1641 margin-top: 10px; 1642 } 1643 1644 .advanced .hidden { 1645 display: none; 1579 1646 } 1580 1647 1581 1648 /* Drag & drop on the editor upload */ … … 1780 1847 top: 40%; 1781 1848 } 1782 1849 1850 .image-details .media-modal { 1851 left: 30px; 1852 right: 30px; 1853 } 1854 1783 1855 .media-selection { 1784 1856 min-width: 120px; 1785 1857 } … … 1848 1920 display: none; 1849 1921 } 1850 1922 1923 .image-details .media-frame-title { 1924 display: block; 1925 top: 0; 1926 font-size: 14px; 1927 } 1928 1851 1929 .media-frame-toolbar { 1852 1930 position: absolute; 1853 1931 bottom: 0px; … … 1904 1982 top: 118px; 1905 1983 } 1906 1984 1985 .image-details .media-frame.hide-router .media-frame-content { 1986 top: 40px; 1987 } 1988 1907 1989 .media-frame .attachments-browser { 1908 1990 padding-bottom: 300px; 1909 1991 } … … 1938 2020 } 1939 2021 1940 2022 /* Full-bleed modal */ 1941 .media-modal { 2023 .media-modal, 2024 .image-details .media-modal { 1942 2025 position: fixed; 1943 2026 top: 0; 1944 2027 left: 0; … … 1974 2057 padding-bottom: 52px; 1975 2058 } 1976 2059 2060 .image-details .column-settings, 2061 .image-details .column-image { 2062 float: none; 2063 width: 100%; 2064 } 2065 1977 2066 /* Gallery */ 1978 2067 .media-frame.hide-router .media-frame-content { 1979 2068 top: 73px; -
src/wp-includes/js/media-views.js
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js index be0ee8f..d8cb86a 100644
761 761 initialize: function( options ) { 762 762 this.image = options.image; 763 763 media.controller.State.prototype.initialize.apply( this, arguments ); 764 }, 765 766 activate: function() { 767 this.frame.modal.$el.addClass('image-details'); 764 768 } 765 769 }); 766 770 … … 2556 2560 2557 2561 }, 2558 2562 2559 2560 2563 renderMenu: function( view ) { 2561 2564 var lastState = this.lastState(), 2562 2565 previous = lastState && lastState.id, … … 2611 2614 }, 2612 2615 2613 2616 renderReplaceImageToolbar: function() { 2617 var frame = this, 2618 lastState = frame.lastState(), 2619 previous = lastState && lastState.id; 2620 2614 2621 this.toolbar.set( new media.view.Toolbar({ 2615 2622 controller: this, 2616 2623 items: { 2624 back: { 2625 text: l10n.back, 2626 priority: 20, 2627 click: function() { 2628 if ( previous ) { 2629 frame.setState( previous ); 2630 } else { 2631 frame.close(); 2632 } 2633 } 2634 }, 2635 2617 2636 replace: { 2618 2637 style: 'primary', 2619 2638 text: l10n.replace, … … 5904 5923 className: 'image-details', 5905 5924 template: media.template('image-details'), 5906 5925 events: _.defaults( media.view.Settings.AttachmentDisplay.prototype.events, { 5907 'click .edit-attachment': 'editAttachment' 5926 'click .edit-attachment': 'editAttachment', 5927 'click .replace-attachment': 'replaceAttachment', 5928 'click .show-advanced': 'showAdvanced' 5908 5929 } ), 5909 5930 initialize: function() { 5910 5931 // used in AttachmentDisplay.prototype.updateLinkTo 5911 5932 this.options.attachment = this.model.attachment; 5912 5933 if ( this.model.attachment ) { 5913 this.listenTo( this.model.attachment, 'change:url', this.updateUrl ); 5934 this.listenTo( this.model, 'change:url', this.updateUrl ); 5935 this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); 5914 5936 } 5915 5937 media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments ); 5916 5938 }, … … 5945 5967 }, 5946 5968 5947 5969 resetFocus: function() { 5948 this.$( '. caption textarea' ).focus();5949 this.$( '.embed- image-settings' ).scrollTop( 0 );5970 this.$( '.link-to-custom' ).blur(); 5971 this.$( '.embed-media-settings' ).scrollTop( 0 ); 5950 5972 }, 5951 5973 5952 5974 updateUrl: function() { 5953 this.$( '. thumbnailimg' ).attr( 'src', this.model.get('url' ) );5975 this.$( '.image img' ).attr( 'src', this.model.get('url' ) ); 5954 5976 this.$( '.url' ).val( this.model.get('url' ) ); 5955 5977 }, 5956 5978 5979 toggleLinkSettings: function() { 5980 if ( this.model.get( 'link' ) === 'none' ) { 5981 this.$( '.link-settings' ).addClass('hidden'); 5982 } else { 5983 this.$( '.link-settings' ).removeClass('hidden'); 5984 } 5985 }, 5986 5987 showAdvanced: function( event ) { 5988 event.preventDefault(); 5989 $( event.target ).closest('.advanced') 5990 .find( '.hidden' ).removeClass( 'hidden' ); 5991 $( event.target ).remove(); 5992 5993 5994 }, 5995 5957 5996 editAttachment: function( event ) { 5958 5997 var editState = this.controller.state( 'edit-image' ); 5959 5998 … … 5962 6001 editState.set( 'image', this.model.attachment ); 5963 6002 this.controller.setState( 'edit-image' ); 5964 6003 } 6004 }, 6005 6006 replaceAttachment: function( event ) { 6007 event.preventDefault(); 6008 this.controller.setState( 'replace-image' ); 5965 6009 } 5966 6010 }); 5967 6011 -
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 2d2e587..f0a5807 100644
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 112 112 } 113 113 114 114 function extractImageData( imageNode ) { 115 var classes, metadata, captionBlock, caption, 115 var classes, metadata, captionBlock, caption, link, 116 116 dom = editor.dom; 117 117 118 118 // default attributes … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 121 121 url: false, 122 122 height: '', 123 123 width: '', 124 size: 'none',124 size: false, 125 125 caption: '', 126 126 alt: '', 127 127 align: 'none', 128 128 link: false, 129 linkUrl: '' 129 linkUrl: '', 130 linkClassName: '', 131 linkTargetBlank: false, 132 linkRel: '', 133 title: '', 134 className: '' 130 135 }; 131 136 132 137 metadata.url = dom.getAttrib( imageNode, 'src' ); 133 138 metadata.alt = dom.getAttrib( imageNode, 'alt' ); 139 metadata.title = dom.getAttrib( imageNode, 'title' ); 134 140 metadata.width = parseInt( dom.getAttrib( imageNode, 'width' ), 10 ); 135 141 metadata.height = parseInt( dom.getAttrib( imageNode, 'height' ), 10 ); 142 metadata.className = imageNode.className; 136 143 137 //TODO: probably should capture attributes on both the <img /> and the <a /> so that they can be restored 138 // when the image and/or caption are updated 139 // maybe use getAttribs() 140 141 // extract meta data from classes (candidate for turning into a method) 142 classes = imageNode.className.split( ' ' ); 144 classes = metadata.className.split( ' ' ); 143 145 tinymce.each( classes, function( name ) { 144 146 145 147 if ( /^wp-image/.test( name ) ) { … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 155 157 } 156 158 } ); 157 159 158 // extract caption160 // Extract caption 159 161 captionBlock = dom.getParents( imageNode, '.wp-caption' ); 160 162 161 163 if ( captionBlock.length ) { … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 171 173 caption = dom.select( 'dd.wp-caption-dd', captionBlock ); 172 174 if ( caption.length ) { 173 175 caption = caption[0]; 174 // need to do some more thinking about this 176 175 177 metadata.caption = editor.serializer.serialize( caption ) 176 178 .replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' ); 177 179 } 178 180 } 179 181 180 // extract linkTo182 // Extract linkTo 181 183 if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { 182 metadata.linkUrl = dom.getAttrib( imageNode.parentNode, 'href' ); 184 link = imageNode.parentNode; 185 metadata.linkUrl = dom.getAttrib( link, 'href' ); 186 metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false; 187 metadata.linkRel = dom.getAttrib( link, 'rel' ); 188 metadata.linkClassName = link.className; 183 189 } 184 190 185 191 return metadata; … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 222 228 nodeToReplace = imageNode.parentNode; 223 229 } 224 230 } 225 // uniqueId isn't super exciting, so maybe we want to use something else 231 226 232 uid = editor.dom.uniqueId( 'wp_' ); 227 233 editor.dom.setAttrib( node, 'data-wp-replace-id', uid ); 228 234 editor.dom.replace( node, nodeToReplace ); … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 245 251 246 252 function createImageAndLink( imageData, mode ) { 247 253 var classes = [], 248 props;254 attrs, linkAttrs; 249 255 250 256 mode = mode ? mode : 'node'; 251 257 … … tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 260 266 } 261 267 } 262 268 263 props = {269 attrs = { 264 270 src: imageData.url, 265 271 width: imageData.width, 266 272 height: imageData.height, 267 alt: imageData.alt 273 alt: imageData.alt, 274 title: imageData.title 268 275 }; 269 276 270 277 if ( classes.length ) { 271 props['class'] = classes.join( ' ' );278 attrs['class'] = classes.join( ' ' ); 272 279 } 273 280 274 281 if ( imageData.linkUrl ) { 282 283 linkAttrs = { 284 href: imageData.linkUrl 285 }; 286 287 if ( imageData.linkRel ) { 288 linkAttrs.rel = imageData.linkRel; 289 } 290 291 console.log( imageData ); 292 if ( imageData.linkTargetBlank ) { 293 linkAttrs.target = '_blank'; 294 } 295 296 if ( imageData.linkClassName ) { 297 linkAttrs['class'] = imageData.linkClassName; 298 } 299 275 300 if ( mode === 'node' ) { 276 return editor.dom.create( 'a', { href: imageData.linkUrl }, editor.dom.createHTML( 'img', props ) );301 return editor.dom.create( 'a', linkAttrs, editor.dom.createHTML( 'img', attrs ) ); 277 302 } else if ( mode === 'html' ) { 278 return editor.dom.createHTML( 'a', { href: imageData.linkUrl }, editor.dom.createHTML( 'img', props ) );303 return editor.dom.createHTML( 'a', linkAttrs, editor.dom.createHTML( 'img', attrs ) ); 279 304 } 305 280 306 } else if ( mode === 'node' ) { 281 return editor.dom.create( 'img', props );307 return editor.dom.create( 'img', attrs ); 282 308 } else if ( mode === 'html' ) { 283 return editor.dom.createHTML( 'img', props );309 return editor.dom.createHTML( 'img', attrs ); 284 310 } 285 311 } 286 312 -
src/wp-includes/media-template.php
diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php index 49cbe90..d2333b5 100644
function wp_print_media_templates() { 667 667 </script> 668 668 669 669 <script type="text/html" id="tmpl-image-details"> 670 <?php // reusing .media-embed to pick up the styles for now ?>671 670 <div class="media-embed"> 672 671 <div class="embed-media-settings"> 673 <div class="thumbnail"> 674 <img src="{{ data.model.url }}" draggable="false" /> 675 </div> 676 <# if ( data.attachment && window.imageEdit ) { #> 677 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Image' ); ?>" /> 678 <# } #> 679 680 <div class="setting url"> 681 <?php // might want to make the url editable if it isn't an attachment ?> 682 <input type="text" disabled="disabled" value="{{ data.model.url }}" /> 683 </div> 672 <div class="column-settings"> 673 <?php 674 /** This filter is documented in wp-admin/includes/media.php */ 675 if ( ! apply_filters( 'disable_captions', '' ) ) : ?> 676 <label class="setting caption"> 677 <span><?php _e('Caption'); ?></span> 678 <textarea data-setting="caption">{{ data.model.caption }}</textarea> 679 </label> 680 <?php endif; ?> 684 681 685 <?php 686 /** This filter is documented in wp-admin/includes/media.php */ 687 if ( ! apply_filters( 'disable_captions', '' ) ) : ?> 688 <label class="setting caption"> 689 <span><?php _e('Caption'); ?></span> 690 <textarea data-setting="caption">{{ data.model.caption }}</textarea> 682 <label class="setting alt-text"> 683 <span><?php _e('Alternative Text'); ?></span> 684 <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> 691 685 </label> 692 <?php endif; ?>693 686 694 <label class="setting alt-text"> 695 <span><?php _e('Alt Text'); ?></span> 696 <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> 697 </label> 687 <div class="advanced"> 688 <a class="show-advanced" href="#"><?php _e('show advanced'); ?></a> 689 <div class="hidden"> 690 <label class="setting title-text"> 691 <span><?php _e('Title Attribute'); ?></span> 692 <input type="text" data-setting="title" value="{{ data.model.title }}" /> 693 </label> 694 </div> 695 </div> 698 696 699 <div class="setting align"> 700 <span><?php _e('Align'); ?></span> 701 <div class="button-group button-large" data-setting="align"> 702 <button class="button" value="left"> 703 <?php esc_attr_e('Left'); ?> 704 </button> 705 <button class="button" value="center"> 706 <?php esc_attr_e('Center'); ?> 707 </button> 708 <button class="button" value="right"> 709 <?php esc_attr_e('Right'); ?> 710 </button> 711 <button class="button active" value="none"> 712 <?php esc_attr_e('None'); ?> 713 </button> 697 <div class="setting align"> 698 <span><?php _e('Align'); ?></span> 699 <div class="button-group button-large" data-setting="align"> 700 <button class="button" value="left"> 701 <?php esc_attr_e('Left'); ?> 702 </button> 703 <button class="button" value="center"> 704 <?php esc_attr_e('Center'); ?> 705 </button> 706 <button class="button" value="right"> 707 <?php esc_attr_e('Right'); ?> 708 </button> 709 <button class="button active" value="none"> 710 <?php esc_attr_e('None'); ?> 711 </button> 712 </div> 714 713 </div> 715 </div> 716 <div class="setting link-to"> 717 <span><?php _e('Link To'); ?></span> 718 <div class="button-group button-large" data-setting="link"> 714 719 715 <# if ( data.attachment ) { #> 720 <button class="button" value="file"> 721 <?php esc_attr_e('Media File'); ?> 722 </button> 723 <button class="button" value="post"> 724 <?php esc_attr_e('Attachment Page'); ?> 725 </button> 726 <# } else { #> 727 <button class="button" value="file"> 728 <?php esc_attr_e('Image URL'); ?> 729 </button> 716 <div class="setting size"> 717 <span><?php _e('Size'); ?></span> 718 <div class="button-group button-large" data-setting="size"> 719 <?php 720 /** This filter is documented in wp-admin/includes/media.php */ 721 $sizes = apply_filters( 'image_size_names_choose', array( 722 'thumbnail' => __('Thumbnail'), 723 'medium' => __('Medium'), 724 'large' => __('Large'), 725 'full' => __('Full Size'), 726 ) ); 727 728 foreach ( $sizes as $value => $name ) : ?> 729 <# var size = data.attachment.sizes['<?php echo esc_js( $value ); ?>']; 730 if ( size ) { #> 731 <button class="button" value="<?php echo esc_attr( $value ); ?>"> 732 <?php echo esc_html( $name ); ?> 733 </button> 734 <# } #> 735 <?php endforeach; ?> 736 </div> 737 </div> 730 738 <# } #> 731 <button class="button" value="custom"> 732 <?php esc_attr_e('Custom URL'); ?> 733 </button> 734 <button class="button active" value="none"> 735 <?php esc_attr_e('None'); ?> 736 </button> 739 740 <div class="setting link-to"> 741 <span><?php _e('Link To'); ?></span> 742 <div class="button-group button-large" data-setting="link"> 743 <# if ( data.attachment ) { #> 744 <button class="button" value="file"> 745 <?php esc_attr_e('Media File'); ?> 746 </button> 747 <button class="button" value="post"> 748 <?php esc_attr_e('Attachment Page'); ?> 749 </button> 750 <# } else { #> 751 <button class="button" value="file"> 752 <?php esc_attr_e('Image URL'); ?> 753 </button> 754 <# } #> 755 <button class="button" value="custom"> 756 <?php esc_attr_e('Custom URL'); ?> 757 </button> 758 <button class="button active" value="none"> 759 <?php esc_attr_e('None'); ?> 760 </button> 761 </div> 762 <input type="text" class="link-to-custom" data-setting="linkUrl" /> 737 763 </div> 738 <input type="text" class="link-to-custom" data-setting="linkUrl" />739 </div>740 764 741 <# if ( data.attachment ) { #> 742 <div class="setting size"> 743 <span><?php _e('Size'); ?></span> 744 <div class="button-group button-large" data-setting="size"> 745 <?php 746 /** This filter is documented in wp-admin/includes/media.php */ 747 $sizes = apply_filters( 'image_size_names_choose', array( 748 'thumbnail' => __('Thumbnail'), 749 'medium' => __('Medium'), 750 'large' => __('Large'), 751 'full' => __('Full Size'), 752 ) ); 753 754 foreach ( $sizes as $value => $name ) : ?> 755 <# var size = data.attachment.sizes['<?php echo esc_js( $value ); ?>']; 756 if ( size ) { #> 757 <button class="button" value="<?php echo esc_attr( $value ); ?>"> 758 <?php echo esc_html( $name ); ?> 759 </button> 760 <# } #> 761 <?php endforeach; ?> 765 766 <div class="link-settings"> 767 <div class="setting link-target"> 768 <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new window/tab' ); ?></label> 769 </div> 770 <div class="advanced"> 771 <a class="show-advanced" href="#"><?php _e('show advanced'); ?></a> 772 <div class="hidden"> 773 <label class="setting link-rel"> 774 <span><?php _e('Link Rel'); ?></span> 775 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> 776 </label> 777 <label class="setting link-class-name"> 778 <span><?php _e('CSS Class'); ?></span> 779 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> 780 </label> 781 </div> 762 782 </div> 763 783 </div> 764 <# } #> 784 785 </div> 786 <div class="column-image"> 787 <div class="image"> 788 <img src="{{ data.model.url }}" draggable="false" /> 789 </div> 790 <# if ( data.attachment && window.imageEdit ) { #> 791 <div class="actions"> 792 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" /> 793 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" /> 794 </div> 795 <# } #> 796 </div> 765 797 </div> 766 798 </div> 767 799 </script>