Ticket #27366: 27366-01.patch
File 27366-01.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..b556866 100644
1513 1513 overflow: auto; 1514 1514 } 1515 1515 1516 .image-details .media-modal { 1517 left: 100px; 1518 right: 100px; 1519 } 1520 1521 .image-details .media-frame-menu { 1522 display: none; 1523 } 1524 1525 .image-details .media-frame-title, 1526 .image-details .media-frame-content, 1527 .image-details .media-frame-router { 1528 left: 0; 1529 } 1530 1516 1531 .image-details .embed-media-settings { 1517 1532 top: 0; 1533 overflow: visible; 1534 } 1535 1536 .image-details .column-settings { 1537 width: 44%; 1538 float: left; 1539 margin-right: 20px; 1540 } 1541 1542 .image-details .column-image { 1543 width: 53%; 1544 float: left; 1545 } 1546 1547 .image-details .image img { 1548 max-width: 100%; 1549 max-height: 500px; 1518 1550 } 1519 1551 1552 1520 1553 .media-embed .thumbnail { 1521 1554 max-width: 100%; 1522 1555 max-height: 200px; … … 1529 1562 display: block; 1530 1563 } 1531 1564 1532 .media-embed .edit-attachment {1533 margin-left: 10px;1534 }1535 1536 1565 .media-embed .thumbnail:after { 1537 1566 content: ''; 1538 1567 display: block; … … 1554 1583 clear: both; 1555 1584 } 1556 1585 1557 .media-embed .setting .hidden { 1586 .image-details .setting { 1587 float: none; 1588 } 1589 1590 .image-details .actions { 1591 margin: 10px 0; 1592 } 1593 1594 .media-embed .setting input[type="text"], 1595 .media-embed .setting textarea { 1596 display: block; 1597 width: 100%; 1598 max-width: 400px; 1599 margin: 1px 0; 1600 } 1601 1602 .image-details .setting input[type="text"], 1603 .image-details .setting textarea { 1604 max-width: inherit; 1605 } 1606 1607 .media-embed .setting input.hidden { 1558 1608 display: none; 1559 1609 } 1560 1610 … … 1570 1620 margin: 2px 0; 1571 1621 } 1572 1622 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; 1623 .media-embed-sidebar { 1624 position: absolute; 1625 top: 0; 1626 left: 440px; 1627 } 1628 1629 .advanced, 1630 .link-settings { 1631 margin-top: 10px; 1632 } 1633 1634 .advanced .hidden { 1635 display: none; 1579 1636 } 1580 1637 1581 1638 /* Drag & drop on the editor upload */ … … 1780 1837 top: 40%; 1781 1838 } 1782 1839 1840 .image-details .media-modal { 1841 left: 30px; 1842 right: 30px; 1843 } 1844 1783 1845 .media-selection { 1784 1846 min-width: 120px; 1785 1847 } … … 1848 1910 display: none; 1849 1911 } 1850 1912 1913 .image-details .media-frame-title { 1914 display: block; 1915 top: 0; 1916 font-size: 14px; 1917 } 1918 1851 1919 .media-frame-toolbar { 1852 1920 position: absolute; 1853 1921 bottom: 0px; … … 1904 1972 top: 118px; 1905 1973 } 1906 1974 1975 .image-details .media-frame.hide-router .media-frame-content { 1976 top: 40px; 1977 } 1978 1907 1979 .media-frame .attachments-browser { 1908 1980 padding-bottom: 300px; 1909 1981 } … … 1938 2010 } 1939 2011 1940 2012 /* Full-bleed modal */ 1941 .media-modal { 2013 .media-modal, 2014 .image-details .media-modal { 1942 2015 position: fixed; 1943 2016 top: 0; 1944 2017 left: 0; … … 1974 2047 padding-bottom: 52px; 1975 2048 } 1976 2049 2050 .image-details .column-settings, 2051 .image-details .column-image { 2052 float: none; 2053 width: 100%; 2054 } 2055 1977 2056 /* Gallery */ 1978 2057 .media-frame.hide-router .media-frame-content { 1979 2058 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..e13c057 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'); 768 }, 769 770 deactivate: function() { 771 this.frame.modal.$el.addClass('image-details'); 764 772 } 765 773 }); 766 774 … … 2556 2564 2557 2565 }, 2558 2566 2559 2560 2567 renderMenu: function( view ) { 2561 2568 var lastState = this.lastState(), 2562 2569 previous = lastState && lastState.id, … … 2611 2618 }, 2612 2619 2613 2620 renderReplaceImageToolbar: function() { 2621 var frame = this, 2622 lastState = frame.lastState(), 2623 previous = lastState && lastState.id; 2624 2614 2625 this.toolbar.set( new media.view.Toolbar({ 2615 2626 controller: this, 2616 2627 items: { 2628 back: { 2629 text: l10n.back, 2630 priority: 20, 2631 click: function() { 2632 if ( previous ) { 2633 frame.setState( previous ); 2634 } else { 2635 frame.close(); 2636 } 2637 } 2638 }, 2639 2617 2640 replace: { 2618 2641 style: 'primary', 2619 2642 text: l10n.replace, … … 5904 5927 className: 'image-details', 5905 5928 template: media.template('image-details'), 5906 5929 events: _.defaults( media.view.Settings.AttachmentDisplay.prototype.events, { 5907 'click .edit-attachment': 'editAttachment' 5930 'click .edit-attachment': 'editAttachment', 5931 'click .replace-attachment': 'replaceAttachment', 5932 'click .show-advanced': 'showAdvanced' 5908 5933 } ), 5909 5934 initialize: function() { 5910 5935 // used in AttachmentDisplay.prototype.updateLinkTo 5911 5936 this.options.attachment = this.model.attachment; 5912 5937 if ( this.model.attachment ) { 5913 this.listenTo( this.model.attachment, 'change:url', this.updateUrl ); 5938 this.listenTo( this.model, 'change:url', this.updateUrl ); 5939 this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); 5914 5940 } 5915 5941 media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments ); 5916 5942 }, … … 5945 5971 }, 5946 5972 5947 5973 resetFocus: function() { 5948 this.$( '. caption textarea' ).focus();5949 this.$( '.embed- image-settings' ).scrollTop( 0 );5974 this.$( '.link-to-custom' ).blur(); 5975 this.$( '.embed-media-settings' ).scrollTop( 0 ); 5950 5976 }, 5951 5977 5952 5978 updateUrl: function() { 5953 this.$( '. thumbnailimg' ).attr( 'src', this.model.get('url' ) );5979 this.$( '.image img' ).attr( 'src', this.model.get('url' ) ); 5954 5980 this.$( '.url' ).val( this.model.get('url' ) ); 5955 5981 }, 5956 5982 5983 toggleLinkSettings: function() { 5984 if ( this.model.get( 'link' ) === 'none' ) { 5985 this.$( '.link-settings' ).addClass('hidden'); 5986 } else { 5987 this.$( '.link-settings' ).removeClass('hidden'); 5988 } 5989 }, 5990 5991 showAdvanced: function( event ) { 5992 event.preventDefault(); 5993 $( event.target ).closest('.advanced') 5994 .find( '.hidden' ).removeClass( 'hidden' ); 5995 $( event.target ).remove(); 5996 5997 5998 }, 5999 5957 6000 editAttachment: function( event ) { 5958 6001 var editState = this.controller.state( 'edit-image' ); 5959 6002 … … 5962 6005 editState.set( 'image', this.model.attachment ); 5963 6006 this.controller.setState( 'edit-image' ); 5964 6007 } 6008 }, 6009 6010 replaceAttachment: function( event ) { 6011 event.preventDefault(); 6012 this.controller.setState( 'replace-image' ); 5965 6013 } 5966 6014 }); 5967 6015 -
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..7f15353 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"> 719 <# 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> 730 <# } #> 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> 714 <div class="setting link-to"> 715 <span><?php _e('Link To'); ?></span> 716 <div class="button-group button-large" data-setting="link"> 717 <# if ( data.attachment ) { #> 718 <button class="button" value="file"> 719 <?php esc_attr_e('Media File'); ?> 720 </button> 721 <button class="button" value="post"> 722 <?php esc_attr_e('Attachment Page'); ?> 723 </button> 724 <# } else { #> 725 <button class="button" value="file"> 726 <?php esc_attr_e('Image URL'); ?> 727 </button> 728 <# } #> 729 <button class="button" value="custom"> 730 <?php esc_attr_e('Custom URL'); ?> 731 </button> 732 <button class="button active" value="none"> 733 <?php esc_attr_e('None'); ?> 734 </button> 735 </div> 736 <input type="text" class="link-to-custom" data-setting="linkUrl" /> 737 737 </div> 738 <input type="text" class="link-to-custom" data-setting="linkUrl" />739 </div>740 738 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; ?> 739 740 <div class="link-settings"> 741 <div class="setting link-target"> 742 <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> 743 </div> 744 <div class="advanced"> 745 <a class="show-advanced" href="#"><?php _e('show advanced'); ?></a> 746 <div class="hidden"> 747 <label class="setting link-rel"> 748 <span><?php _e('Link Rel'); ?></span> 749 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> 750 </label> 751 <label class="setting link-class-name"> 752 <span><?php _e('CSS Class'); ?></span> 753 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> 754 </label> 755 </div> 762 756 </div> 763 757 </div> 764 <# } #> 758 759 <# if ( data.attachment ) { #> 760 <div class="setting size"> 761 <span><?php _e('Size'); ?></span> 762 <div class="button-group button-large" data-setting="size"> 763 <?php 764 /** This filter is documented in wp-admin/includes/media.php */ 765 $sizes = apply_filters( 'image_size_names_choose', array( 766 'thumbnail' => __('Thumbnail'), 767 'medium' => __('Medium'), 768 'large' => __('Large'), 769 'full' => __('Full Size'), 770 ) ); 771 772 foreach ( $sizes as $value => $name ) : ?> 773 <# var size = data.attachment.sizes['<?php echo esc_js( $value ); ?>']; 774 if ( size ) { #> 775 <button class="button" value="<?php echo esc_attr( $value ); ?>"> 776 <?php echo esc_html( $name ); ?> 777 </button> 778 <# } #> 779 <?php endforeach; ?> 780 </div> 781 </div> 782 <# } #> 783 </div> 784 <div class="column-image"> 785 <div class="image"> 786 <img src="{{ data.model.url }}" draggable="false" /> 787 </div> 788 <div class="setting url"> 789 <input type="text" disabled="disabled" value="{{ data.model.url }}" /> 790 </div> 791 <# if ( data.attachment && window.imageEdit ) { #> 792 <div class="actions"> 793 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" /> 794 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" /> 795 </div> 796 <# } #> 797 </div> 765 798 </div> 766 799 </div> 767 800 </script>