Ticket #27389: 27389.3.diff
File 27389.3.diff, 24.2 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-wp-editor.php
343 343 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 344 344 $version = 'ver=' . $GLOBALS['wp_version']; 345 345 $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); 346 $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" ); 347 $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" ); 346 348 347 349 // WordPress default stylesheet and dashicons 348 $mce_css = array( $dashicons, self::$baseurl . '/skins/wordpress/wp-content.css' ); 350 $mce_css = array( 351 $dashicons, 352 $mediaelement, 353 $wpmediaelement, 354 self::$baseurl . '/skins/wordpress/wp-content.css' 355 ); 349 356 350 357 // load editor_style.css if the current theme supports it 351 358 if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { -
src/wp-includes/js/mce-view.js
1 /* global tinymce */1 /* global tinymce, _wpmejsSettings, MediaElementPlayer */ 2 2 3 3 // Ensure the global `wp` object exists. 4 4 window.wp = window.wp || {}; … … 31 31 var html = this.getHtml(); 32 32 // Search all tinymce editor instances and update the placeholders 33 33 _.each( tinymce.editors, function( editor ) { 34 var doc ;34 var doc, self = this; 35 35 if ( editor.plugins.wpview ) { 36 36 doc = editor.getDoc(); 37 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).html( html ); 37 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { 38 var node = $( elem ); 39 node.html( html ); 40 $( self ).trigger( 'ready', elem ); 41 }); 38 42 } 39 43 }, this ); 40 44 } … … 178 182 179 183 /** 180 184 * Refresh views after an update is made 181 * 185 * 182 186 * @param view {object} being refreshed 183 187 * @param text {string} textual representation of the view 184 188 */ … … 204 208 return instances[ encodedText ]; 205 209 }, 206 210 207 /** 211 /** 208 212 * render( scope ) 209 * 213 * 210 214 * Renders any view instances inside a DOM node `scope`. 211 215 * 212 216 * View instances are detected by the presence of wrapper elements. … … 302 306 303 307 }; 304 308 wp.mce.views.register( 'gallery', wp.mce.gallery ); 309 310 wp.mce.media = { 311 toView: function( content ) { 312 var match = wp.shortcode.next( this.shortcode, content ); 313 314 if ( ! match ) { 315 return; 316 } 317 318 return { 319 index: match.index, 320 content: match.content, 321 options: { 322 shortcode: match.shortcode 323 } 324 }; 325 }, 326 327 edit: function( node ) { 328 var p, 329 media = wp.media[ this.shortcode ], 330 self = this, 331 frame, data; 332 333 for (p in window.mejs.players) { 334 window.mejs.players[p].pause(); 335 } 336 337 data = window.decodeURIComponent( $( node ).data('wpview-text') ); 338 frame = media.edit( data ); 339 frame.on( 'close', function () { 340 frame.detach(); 341 } ); 342 frame.state( self.shortcode + '-details' ).on( 'update', function( selection ) { 343 var shortcode = wp.media[ self.shortcode ].update( selection ).string(); 344 $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); 345 wp.mce.views.refreshView( self, shortcode ); 346 frame.detach(); 347 } ); 348 frame.open(); 349 } 350 }; 351 352 wp.mce.media.ViewMixin = wp.mce.View.extend({ 353 initialize: function( options ) { 354 this.shortcode = options.shortcode; 355 _.bindAll( this, 'setPlayer' ); 356 $(this).on( 'ready', this.setPlayer ); 357 }, 358 359 setPlayer: function (e, node) { 360 // if the ready event fires on an empty node 361 if ( ! node ) { 362 return; 363 } 364 365 var id, 366 media, 367 settings = {}, 368 className = '.wp-' + this.shortcode.tag + '-shortcode'; 369 370 media = $( node ).find( className ); 371 372 if ( media.hasClass( 'rendered' ) ) { 373 id = media.closest( className ).attr( 'id' ); 374 window.mejs.players[ id ].remove(); 375 } else { 376 media.addClass( 'rendered' ); 377 } 378 379 media.prop( 'preload', 'none' ); 380 media = media.get(0); 381 382 if ( ! _.isUndefined( window._wpmejsSettings ) ) { 383 settings.pluginPath = _wpmejsSettings.pluginPath; 384 } 385 386 media = wp.media.view.MediaDetails.prepareSrc( media ); 387 new MediaElementPlayer( media, settings ); 388 }, 389 390 getHtml: function() { 391 var attrs = this.shortcode.attrs.named; 392 return this.template({ model: attrs }); 393 } 394 }); 395 396 wp.mce.video = _.extend( {}, wp.mce.media, { 397 shortcode: 'video', 398 View: wp.mce.media.ViewMixin.extend({ 399 className: 'editor-video', 400 template: media.template('editor-video') 401 }) 402 } ); 403 404 wp.mce.views.register( 'video', wp.mce.video ); 405 406 wp.mce.audio = _.extend( {}, wp.mce.media, { 407 shortcode: 'audio', 408 View: wp.mce.media.ViewMixin.extend({ 409 className: 'editor-audio', 410 template: media.template('editor-audio') 411 }) 412 } ); 413 414 wp.mce.views.register( 'audio', wp.mce.audio ); 305 415 }(jQuery)); -
src/wp-includes/js/media-editor.js
581 581 return frame; 582 582 }, 583 583 584 shortcode : function (shortcode) {585 var self = this ;584 update : function (model) { 585 var self = this, content; 586 586 587 _.each( wp.media.audio.defaults, function( value, key ) {588 shortcode[ key ] = self.coerce( shortcode, key );587 _.each( this.defaults, function( value, key ) { 588 model[ key ] = self.coerce( model, key ); 589 589 590 if ( value === shortcode[ key ] ) {591 delete shortcode[ key ];590 if ( value === model[ key ] ) { 591 delete model[ key ]; 592 592 } 593 593 }); 594 594 595 return wp.shortcode.string({ 596 tag: 'audio', 597 attrs: shortcode 595 content = model.content; 596 delete model.content; 597 598 return new wp.shortcode({ 599 tag: 'audio', 600 attrs: model, 601 content: content 598 602 }); 599 603 } 600 604 }, wp.media.mixin); … … 631 635 return frame; 632 636 }, 633 637 634 shortcode : function (shortcode) { 635 var self = this, content = shortcode.content; 636 delete shortcode.content; 638 update : function (model) { 639 var self = this, content = ''; 637 640 638 641 _.each( this.defaults, function( value, key ) { 639 shortcode[ key ] = self.coerce( shortcode, key );642 model[ key ] = self.coerce( model, key ); 640 643 641 if ( value === shortcode[ key ] ) {642 delete shortcode[ key ];644 if ( value === model[ key ] ) { 645 delete model[ key ]; 643 646 } 644 647 }); 645 648 646 return wp.shortcode.string({ 647 tag: 'video', 648 attrs: shortcode, 649 content = model.content; 650 delete model.content; 651 652 return new wp.shortcode({ 653 tag: 'video', 654 attrs: model, 649 655 content: content 650 656 }); 651 657 } … … 1111 1117 * @global wp.media.view.l10n 1112 1118 */ 1113 1119 init: function() { 1114 $(document.body).on( 'click', '.insert-media', function( event ) { 1115 var elem = $( event.currentTarget ), 1116 editor = elem.data('editor'), 1117 options = { 1118 frame: 'post', 1119 state: 'insert', 1120 title: wp.media.view.l10n.addMedia, 1121 multiple: true 1122 }; 1120 $(document.body) 1121 .on( 'click', '.insert-media', function( event ) { 1122 var elem = $( event.currentTarget ), 1123 editor = elem.data('editor'), 1124 options = { 1125 frame: 'post', 1126 state: 'insert', 1127 title: wp.media.view.l10n.addMedia, 1128 multiple: true 1129 }; 1123 1130 1124 event.preventDefault();1131 event.preventDefault(); 1125 1132 1126 // Remove focus from the `.insert-media` button.1127 // Prevents Opera from showing the outline of the button1128 // above the modal.1129 //1130 // See: http://core.trac.wordpress.org/ticket/224451131 elem.blur();1133 // Remove focus from the `.insert-media` button. 1134 // Prevents Opera from showing the outline of the button 1135 // above the modal. 1136 // 1137 // See: http://core.trac.wordpress.org/ticket/22445 1138 elem.blur(); 1132 1139 1133 if ( elem.hasClass( 'gallery' ) ) {1134 options.state = 'gallery';1135 options.title = wp.media.view.l10n.createGalleryTitle;1136 } else if ( elem.hasClass( 'playlist' ) ) {1137 options.state = 'playlist';1138 options.title = wp.media.view.l10n.createPlaylistTitle;1139 } else if ( elem.hasClass( 'video-playlist' ) ) {1140 options.state = 'video-playlist';1141 options.title = wp.media.view.l10n.createVideoPlaylistTitle;1142 }1140 if ( elem.hasClass( 'gallery' ) ) { 1141 options.state = 'gallery'; 1142 options.title = wp.media.view.l10n.createGalleryTitle; 1143 } else if ( elem.hasClass( 'playlist' ) ) { 1144 options.state = 'playlist'; 1145 options.title = wp.media.view.l10n.createPlaylistTitle; 1146 } else if ( elem.hasClass( 'video-playlist' ) ) { 1147 options.state = 'video-playlist'; 1148 options.title = wp.media.view.l10n.createVideoPlaylistTitle; 1149 } 1143 1150 1144 wp.media.editor.open( editor, options ); 1145 }); 1151 wp.media.editor.open( editor, options ); 1152 }) 1153 .on( 'click', '.wp-switch-editor', function () { 1154 var p; 1155 if ( window.mejs && window.mejs.players ) { 1156 for ( p in window.mejs.players ) { 1157 window.mejs.players[p].pause(); 1158 } 1159 } 1160 } ); 1146 1161 1147 1162 // Initialize and render the Editor drag-and-drop uploader. 1148 1163 new wp.media.view.EditorUploader().render(); -
src/wp-includes/js/media-models.js
467 467 this.attachment = attachment; 468 468 this.extension = attachment.get('filename' ).split('.').pop(); 469 469 470 this.unset( 'src' ); 470 471 if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) { 471 472 this.set( this.extension, this.attachment.get( 'url' ) ); 472 473 } else { -
src/wp-includes/js/media-views.js
6542 6542 }, this.options ); 6543 6543 }, 6544 6544 6545 /**6546 * When multiple players in the DOM contain the same src, things get weird.6547 *6548 * @param {HTMLElement} media6549 * @returns {HTMLElement}6550 */6551 prepareSrc : function (media) {6552 var i = wp.media.view.MediaDetails.instances++;6553 _.each( $(media).find('source'), function (source) {6554 source.src = [6555 source.src,6556 source.src.indexOf('?') > -1 ? '&' : '?',6557 '_=',6558 i6559 ].join('');6560 });6561 6562 return media;6563 },6564 6565 6545 removeSetting : function (e) { 6566 6546 var wrap = $( e.currentTarget ).parent(), setting; 6567 6547 … … 6633 6613 }, 6634 6614 6635 6615 unsetPlayer : function() { 6616 var p; 6636 6617 if ( this.player ) { 6637 if ( _.isUndefined( this.mejs.pluginType )) {6638 this.mejs.pause();6618 for ( p in window.mejs.players ) { 6619 window.mejs.players[p].pause(); 6639 6620 } 6640 6621 this.removePlayer(); 6641 6622 this.player = false; … … 6675 6656 this.$( '.embed-media-settings' ).scrollTop( 0 ); 6676 6657 } 6677 6658 }, { 6678 instances : 0 6659 instances : 0, 6660 6661 /** 6662 * When multiple players in the DOM contain the same src, things get weird. 6663 * 6664 * @param {HTMLElement} media 6665 * @returns {HTMLElement} 6666 */ 6667 prepareSrc : function (media) { 6668 var i = wp.media.view.MediaDetails.instances++; 6669 if ( 0 === i ) { 6670 i = (new Date()).getTime(); 6671 } 6672 _.each( $(media).find('source'), function (source) { 6673 source.src = [ 6674 source.src, 6675 source.src.indexOf('?') > -1 ? '&' : '?', 6676 '_=', 6677 i 6678 ].join(''); 6679 }); 6680 6681 return media; 6682 } 6679 6683 }); 6680 6684 6681 6685 /** … … 6694 6698 template: media.template('audio-details'), 6695 6699 6696 6700 setMedia: function() { 6697 var audio = this.$('.wp-audio-shortcode'); 6701 var className = '.wp-audio-shortcode', 6702 audio; 6698 6703 6704 audio = this.$( className ); 6705 6699 6706 if ( audio.find( 'source' ).length ) { 6700 6707 if ( audio.is(':hidden') ) { 6701 6708 audio.show(); 6702 6709 } 6703 this.media = this.prepareSrc( audio.get(0) ); 6710 6711 audio = audio.get(0); 6712 6713 if ( $( className ).length > 0 ) { 6714 audio = media.view.MediaDetails.prepareSrc( audio ); 6715 } 6716 6717 this.media = audio; 6704 6718 } else { 6705 6719 audio.hide(); 6706 6720 this.media = false; … … 6726 6740 template: media.template('video-details'), 6727 6741 6728 6742 setMedia: function() { 6729 var video = this.$('.wp-video-shortcode'); 6743 var className = '.wp-video-shortcode', 6744 video, 6745 yt; 6730 6746 6747 video = this.$( className ); 6748 yt = video.hasClass('youtube-video'); 6749 6731 6750 if ( video.find( 'source' ).length ) { 6732 6751 if ( video.is(':hidden') ) { 6733 6752 video.show(); 6734 6753 } 6735 6754 6736 if ( ! video.hasClass('youtube-video') ) {6737 this.media = this.prepareSrc( video.get(0) ); 6738 } else{6739 this.media = video.get(0);6755 video = video.get(0); 6756 6757 if ( ! yt ) { 6758 video = media.view.MediaDetails.prepareSrc( video ); 6740 6759 } 6760 6761 this.media = video; 6741 6762 } else { 6742 6763 video.hide(); 6743 6764 this.media = false; -
src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js
25 25 } 26 26 27 27 function replaceAVShortcodes( content ) { 28 var testRegex = /\[(video-playlist| audio|video|playlist)[^\]]*\]/,29 replaceRegex = /\[(video-playlist| audio|video|playlist)[^\]]*\]([\s\S]*?\[\/\1\])?/;28 var testRegex = /\[(video-playlist|playlist)[^\]]*\]/, 29 replaceRegex = /\[(video-playlist|playlist)[^\]]*\]([\s\S]*?\[\/\1\])?/; 30 30 31 31 while ( testRegex.test( content ) ) { 32 32 content = content.replace( replaceRegex, replaceCallback ); … … 92 92 editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) ); 93 93 frame.detach(); 94 94 }); 95 } else if ( editor.dom.hasClass( node, 'wp-video' ) ) {96 frame = wp.media.video.edit( data );97 frame.on( 'close', function () {98 frame.detach();99 } );100 frame.state( 'video-details' ).on(101 'update replace add-source select-poster-image add-track',102 function ( selection ) {103 var shortcode = wp.media.video.shortcode( selection );104 editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );105 frame.detach();106 }107 );108 frame.open();109 } else if ( editor.dom.hasClass( node, 'wp-audio' ) ) {110 frame = wp.media.audio.edit( data );111 frame.on( 'close', function () {112 frame.detach();113 } );114 frame.state( 'audio-details' ).on( 'update replace add-source', function ( selection ) {115 var shortcode = wp.media.audio.shortcode( selection );116 editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );117 frame.detach();118 } );119 frame.open();120 95 } else { 121 96 // temp 122 97 window.console && window.console.log( 'Edit AV shortcode ' + data ); -
src/wp-includes/js/tinymce/skins/wordpress/wp-content.css
237 237 /** 238 238 * Gallery preview 239 239 */ 240 .wpview-type-gallery { 240 .wpview-type-gallery, 241 .wpview-type-audio, 242 .wpview-type-video { 241 243 position: relative; 242 244 padding: 0 0 12px; 243 245 margin-bottom: 16px; … … 244 246 cursor: pointer; 245 247 } 246 248 247 .wpview-type-gallery:after { 249 .wpview-type-audio, 250 .wpview-type-video { 251 padding: 32px 0 0; 252 } 253 254 .wpview-type-audio audio, 255 .wpview-type-video video { 256 display: inline-block; 257 max-width: 100%; 258 } 259 260 .wpview-type-gallery:after, 261 .wpview-type-audio:after, 262 .wpview-type-video:after { 248 263 content: ''; 249 264 display: block; 250 265 height: 0; … … 252 267 visibility: hidden; 253 268 } 254 269 255 270 .wpview-type-gallery.selected { 256 271 background-color: #efefef; 257 272 } 258 273 259 .wpview-type-gallery .toolbar { 274 .wpview-type-audio, 275 .wpview-type-video { 276 background-color: #efefef; 277 } 278 279 .wpview-type-gallery .toolbar, 280 .wpview-type-audio .toolbar, 281 .wpview-type-video .toolbar { 260 282 position: absolute; 261 283 top: 0; 262 284 left: 0; … … 266 288 display: none; 267 289 } 268 290 291 .wpview-type-audio .toolbar, 292 .wpview-type-video .toolbar { 293 display: block; 294 } 295 269 296 .wpview-type-gallery.selected .toolbar { 270 297 display: block; 271 298 } 272 299 273 .wpview-type-gallery .toolbar span { 300 .wpview-type-gallery .toolbar span, 301 .wpview-type-audio .toolbar span 302 .wpview-type-video .toolbar span { 274 303 cursor: pointer; 275 304 } 276 305 -
src/wp-includes/media-template.php
8 8 */ 9 9 10 10 /** 11 * Output the markup for a audio tag to be used in an Underscore template 12 * when data.model is passed. 13 * 14 * @since 3.9.0 15 */ 16 function wp_underscore_audio_template() { 17 $audio_types = wp_get_audio_extensions(); 18 ?> 19 <audio controls 20 class="wp-audio-shortcode" 21 preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}" 22 <# 23 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 24 ?>if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 25 #> <?php echo $attr ?><# 26 } 27 <?php endforeach ?>#> 28 > 29 <# if ( ! _.isEmpty( data.model.src ) ) { #> 30 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 31 <# } #> 32 33 <?php foreach ( $audio_types as $type ): 34 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #> 35 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 36 <# } #> 37 <?php endforeach; 38 ?></audio> 39 <?php 40 } 41 42 /** 43 * Output the markup for a video tag to be used in an Underscore template 44 * when data.model is passed. 45 * 46 * @since 3.9.0 47 */ 48 function wp_underscore_video_template( $onload = false ) { 49 $video_types = wp_get_video_extensions(); 50 ?> 51 <# 52 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); 53 w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, 54 h = ! data.model.height ? 360 : data.model.height; 55 56 if ( data.model.width && w !== data.model.width ) { 57 h = Math.ceil( ( h * w ) / data.model.width ); 58 } 59 #> 60 <video controls 61 class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}" 62 width="{{ w }}" 63 height="{{ h }}" 64 <?php 65 $props = array( 'poster' => '', 'preload' => 'metadata' ); 66 foreach ( $props as $key => $value ): 67 if ( empty( $value ) ) { 68 ?><# 69 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) { 70 #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<# 71 } #> 72 <?php } else { 73 echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php 74 } 75 endforeach; 76 ?><# 77 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 78 ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 79 #> <?php echo $attr ?><# 80 } 81 <?php endforeach ?>#> 82 > 83 <# if ( ! _.isEmpty( data.model.src ) ) { 84 if ( isYouTube ) { #> 85 <source src="{{ data.model.src }}" type="video/youtube" /> 86 <# } else { #> 87 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 88 <# } 89 } #> 90 91 <?php foreach ( $video_types as $type ): 92 ?><# if ( data.model.<?php echo $type ?> ) { #> 93 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 94 <# } #> 95 <?php endforeach; ?> 96 {{{ data.model.content }}} 97 </video> 98 <?php 99 } 100 101 /** 11 102 * Prints the templates used in the media manager. 12 103 * 13 104 * @since 3.5.0 … … 676 767 <div class="media-embed media-embed-details"> 677 768 <div class="embed-media-settings embed-audio-settings"> 678 769 <div class="instructions media-instructions">{{{ wp.media.view.l10n.audioDetailsText }}}</div> 679 <audio controls 680 class="wp-audio-shortcode" 681 preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}" 682 <# 683 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 684 ?>if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 685 #> <?php echo $attr ?><# 686 } 687 <?php endforeach ?>#> 688 > 689 <# if ( ! _.isEmpty( data.model.src ) ) { #> 690 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 691 <# } #> 692 693 <?php foreach ( $audio_types as $type ): 694 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #> 695 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 696 <# } #> 697 <?php endforeach; 698 ?></audio> 770 <?php wp_underscore_audio_template() ?> 699 771 <# if ( ! _.isEmpty( data.model.src ) ) { #> 700 772 <label class="setting"> 701 773 <span>SRC</span> … … 738 810 </div> 739 811 </script> 740 812 813 <script type="text/html" id="tmpl-editor-audio"> 814 <div class="toolbar"> 815 <div class="dashicons dashicons-format-audio edit"></div> 816 <div class="dashicons dashicons-no-alt remove"></div> 817 </div> 818 <?php wp_underscore_audio_template() ?> 819 </script> 820 741 821 <script type="text/html" id="tmpl-video-details"> 742 822 <?php $video_types = wp_get_video_extensions(); ?> 743 823 <div class="media-embed media-embed-details"> … … 744 824 <div class="embed-media-settings embed-video-settings"> 745 825 <div class="instructions media-instructions">{{{ wp.media.view.l10n.videoDetailsText }}}</div> 746 826 <div class="wp-video-holder"> 747 <# 748 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); 749 w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, 750 h = ! data.model.height ? 360 : data.model.height; 751 752 if ( data.model.width && w !== data.model.width ) { 753 h = Math.ceil( ( h * w ) / data.model.width ); 754 } 755 756 #> 757 <video controls 758 class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}" 759 width="{{ w }}" 760 height="{{ h }}" 761 <?php 762 $props = array( 'poster' => '', 'preload' => 'metadata' ); 763 foreach ( $props as $key => $value ): 764 if ( empty( $value ) ) { 765 ?><# 766 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) { 767 #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<# 768 } #> 769 <?php } else { 770 echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php 771 } 772 endforeach; 773 ?><# 774 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 775 ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 776 #> <?php echo $attr ?><# 777 } 778 <?php endforeach ?>#> 779 > 780 <# if ( ! _.isEmpty( data.model.src ) ) { 781 if ( isYouTube ) { #> 782 <source src="{{ data.model.src }}" type="video/youtube" /> 783 <# } else { #> 784 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 785 <# } 786 } #> 787 788 <?php foreach ( $video_types as $type ): 789 ?><# if ( data.model.<?php echo $type ?> ) { #> 790 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 791 <# } #> 792 <?php endforeach; ?> 793 {{{ data.model.content }}} 794 </video> 827 <?php wp_underscore_video_template() ?> 795 828 <# if ( ! _.isEmpty( data.model.src ) ) { #> 796 829 <label class="setting"> 797 830 <span>SRC</span> … … 857 890 </div> 858 891 </div> 859 892 </script> 893 894 <script type="text/html" id="tmpl-editor-video"> 895 <div class="toolbar"> 896 <div class="dashicons dashicons-format-video edit"></div> 897 <div class="dashicons dashicons-no-alt remove"></div> 898 </div> 899 <?php wp_underscore_video_template() ?> 900 </script> 860 901 <?php 861 902 862 903 //TODO: do we want to deal with the fact that the elements used for gallery items are filterable and can be overriden via shortcode attributes