Ticket #27389: 27389.5.diff
File 27389.5.diff, 29.7 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 if ( window.mejs && window.mejs.players ) { 334 for ( p in window.mejs.players ) { 335 window.mejs.players[p].pause(); 336 } 337 } 338 339 data = window.decodeURIComponent( $( node ).data('wpview-text') ); 340 frame = media.edit( data ); 341 frame.on( 'close', function () { 342 frame.detach(); 343 } ); 344 frame.state( self.shortcode + '-details' ).on( 'update', function( selection ) { 345 var shortcode = wp.media[ self.shortcode ].update( selection ).string(); 346 $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); 347 wp.mce.views.refreshView( self, shortcode ); 348 frame.detach(); 349 } ); 350 frame.open(); 351 } 352 }; 353 354 wp.mce.media.View = wp.mce.View.extend({ 355 initialize: function( options ) { 356 this.shortcode = options.shortcode; 357 _.bindAll( this, 'setPlayer' ); 358 $(this).on( 'ready', this.setPlayer ); 359 }, 360 361 setPlayer: function (e, node) { 362 // if the ready event fires on an empty node 363 if ( ! node ) { 364 return; 365 } 366 367 var self = this, 368 media, 369 settings = {}, 370 className = '.wp-' + this.shortcode.tag + '-shortcode'; 371 372 if ( this.player ) { 373 this.unsetPlayer(); 374 } 375 376 media = $( node ).find( className ); 377 378 if ( ! _.isUndefined( window._wpmejsSettings ) ) { 379 settings.pluginPath = _wpmejsSettings.pluginPath; 380 } 381 382 if ( ! this.isCompatible( media ) ) { 383 media.closest( '.wpview-wrap' ).addClass( 'wont-play' ); 384 if ( ! media.parent().hasClass( 'wpview-wrap' ) ) { 385 media.parent().replaceWith( media ); 386 } 387 media.replaceWith( '<p>' + media.find( 'source' ).eq(0).prop( 'src' ) + '</p>' ); 388 return; 389 } else { 390 media.closest( '.wpview-wrap' ).removeClass( 'wont-play' ); 391 media.prop( 'preload', 'none' ); 392 } 393 394 media = wp.media.view.MediaDetails.prepareSrc( media.get(0) ); 395 396 // Thanks, Firefox! 397 setTimeout(function () { 398 self.player = new MediaElementPlayer( media, settings ); 399 }, 10); 400 }, 401 402 getHtml: function() { 403 var attrs = this.shortcode.attrs.named; 404 return this.template({ model: attrs }); 405 } 406 }); 407 _.extend( wp.mce.media.View.prototype, wp.media.mixin ); 408 409 wp.mce.video = _.extend( {}, wp.mce.media, { 410 shortcode: 'video', 411 View: wp.mce.media.View.extend({ 412 className: 'editor-video', 413 template: media.template('editor-video') 414 }) 415 } ); 416 417 wp.mce.views.register( 'video', wp.mce.video ); 418 419 wp.mce.audio = _.extend( {}, wp.mce.media, { 420 shortcode: 'audio', 421 View: wp.mce.media.View.extend({ 422 className: 'editor-audio', 423 template: media.template('editor-audio') 424 }) 425 } ); 426 427 wp.mce.views.register( 'audio', wp.mce.audio ); 305 428 }(jQuery)); -
src/wp-includes/js/media-editor.js
296 296 attrs[ key ] = false; 297 297 } 298 298 return attrs[ key ]; 299 }, 300 301 isCompatible: function ( media ) { 302 var ua = window.navigator.userAgent.toLowerCase(), 303 ff = false, safari = false, chrome = false, 304 isIE = ua.match(/MSIE/gi), 305 isOldIE = ua.match(/MSIE [6-8]/gi), 306 isChrome = ua.match(/safari/gi) !== null && ua.match(/chrome/gi) !== null, 307 isFirefox = ua.match(/firefox/gi) !== null, 308 isSafari = ua.match(/safari/gi) !== null && ! ua.match(/chrome/gi); 309 310 if ( isOldIE || isIE ) { 311 return false; 312 } 313 314 if ( isFirefox || isSafari || isChrome ) { 315 media.find( 'source' ).each(function (i, elem) { 316 if ( elem.type.match(/video\/(ogg|webm)/gi) !== null || 317 ( elem.type.match(/audio\/(ogg|mpeg)/gi) !== null && -1 === elem.src.indexOf('.m4a') ) ) { 318 ff = true; 319 } 320 321 if ( elem.type.match(/video\/(mp4|m4v|mpeg|x-ms-wmv|quicktime)/gi) !== null || 322 ( elem.type.match(/audio\/(mpeg|wav)/gi) !== null ) ) { 323 safari = true; 324 } 325 326 if ( elem.type.match(/video\/(mp4|m4v|mpeg|webm|ogg)/gi) !== null || 327 elem.type.match(/audio\/(ogg|mpeg|x-ms-wma)/gi) !== null ) { 328 chrome = true; 329 } 330 }); 331 332 return ( isSafari && safari ) || ( isFirefox && ff ) || ( isChrome && chrome ); 333 334 } else { 335 return true; 336 } 337 338 return false; 339 }, 340 341 pauseAllPlayers: function () { 342 var p; 343 if ( window.mejs && window.mejs.players ) { 344 for ( p in window.mejs.players ) { 345 window.mejs.players[p].pause(); 346 } 347 } 348 }, 349 350 /** 351 * Override the MediaElement method for removing a player. 352 * MediaElement tries to pull the audio/video tag out of 353 * its container and re-add it to the DOM. 354 */ 355 removePlayer: function() { 356 var t = this.player, featureIndex, feature; 357 358 // invoke features cleanup 359 for ( featureIndex in t.options.features ) { 360 feature = t.options.features[featureIndex]; 361 if ( t['clean' + feature] ) { 362 try { 363 t['clean' + feature](t); 364 } catch (e) {} 365 } 366 } 367 368 if ( ! t.isDynamic ) { 369 t.$node.remove(); 370 } 371 372 if ( 'native' !== t.media.pluginType ) { 373 t.media.remove(); 374 } 375 376 delete window.mejs.players[t.id]; 377 378 t.container.remove(); 379 t.globalUnbind(); 380 delete t.node.player; 381 }, 382 383 unsetPlayer : function() { 384 if ( this.player ) { 385 this.pauseAllPlayers(); 386 this.removePlayer(); 387 this.player = false; 388 } 299 389 } 300 390 }; 301 391 … … 302 392 wp.media.collection = function(attributes) { 303 393 var collections = {}; 304 394 305 return _.extend( attributes, wp.media.mixin, { 395 return _.extend( attributes, { 396 coerce : wp.media.mixin.coerce, 397 306 398 /** 307 399 * Retrieve attachments based on the properties of the passed shortcode 308 400 * … … 558 650 /** 559 651 * @namespace 560 652 */ 561 wp.media.audio = _.extend({ 653 wp.media.audio = { 654 coerce : wp.media.mixin.coerce, 655 562 656 defaults : { 563 657 id : wp.media.view.settings.post.id, 564 658 src : '', … … 581 675 return frame; 582 676 }, 583 677 584 shortcode : function (shortcode) {585 var self = this ;678 update : function (model) { 679 var self = this, content; 586 680 587 _.each( wp.media.audio.defaults, function( value, key ) {588 shortcode[ key ] = self.coerce( shortcode, key );681 _.each( this.defaults, function( value, key ) { 682 model[ key ] = self.coerce( model, key ); 589 683 590 if ( value === shortcode[ key ] ) {591 delete shortcode[ key ];684 if ( value === model[ key ] ) { 685 delete model[ key ]; 592 686 } 593 687 }); 594 688 595 return wp.shortcode.string({ 596 tag: 'audio', 597 attrs: shortcode 689 content = model.content; 690 delete model.content; 691 692 return new wp.shortcode({ 693 tag: 'audio', 694 attrs: model, 695 content: content 598 696 }); 599 697 } 600 } , wp.media.mixin);698 }; 601 699 602 700 /** 603 701 * @namespace 604 702 */ 605 wp.media.video = _.extend({ 703 wp.media.video = { 704 coerce : wp.media.mixin.coerce, 705 606 706 defaults : { 607 707 id : wp.media.view.settings.post.id, 608 708 src : '', … … 631 731 return frame; 632 732 }, 633 733 634 shortcode : function (shortcode) { 635 var self = this, content = shortcode.content; 636 delete shortcode.content; 734 update : function (model) { 735 var self = this, content = ''; 637 736 638 737 _.each( this.defaults, function( value, key ) { 639 shortcode[ key ] = self.coerce( shortcode, key );738 model[ key ] = self.coerce( model, key ); 640 739 641 if ( value === shortcode[ key ] ) {642 delete shortcode[ key ];740 if ( value === model[ key ] ) { 741 delete model[ key ]; 643 742 } 644 743 }); 645 744 646 return wp.shortcode.string({ 647 tag: 'video', 648 attrs: shortcode, 745 content = model.content; 746 delete model.content; 747 748 return new wp.shortcode({ 749 tag: 'video', 750 attrs: model, 649 751 content: content 650 752 }); 651 753 } 652 } , wp.media.mixin);754 }; 653 755 654 756 /** 655 757 * wp.media.featuredImage … … 1111 1213 * @global wp.media.view.l10n 1112 1214 */ 1113 1215 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 }; 1216 $(document.body) 1217 .on( 'click', '.insert-media', function( event ) { 1218 var elem = $( event.currentTarget ), 1219 editor = elem.data('editor'), 1220 options = { 1221 frame: 'post', 1222 state: 'insert', 1223 title: wp.media.view.l10n.addMedia, 1224 multiple: true 1225 }; 1123 1226 1124 event.preventDefault();1227 event.preventDefault(); 1125 1228 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();1229 // Remove focus from the `.insert-media` button. 1230 // Prevents Opera from showing the outline of the button 1231 // above the modal. 1232 // 1233 // See: http://core.trac.wordpress.org/ticket/22445 1234 elem.blur(); 1132 1235 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 }1236 if ( elem.hasClass( 'gallery' ) ) { 1237 options.state = 'gallery'; 1238 options.title = wp.media.view.l10n.createGalleryTitle; 1239 } else if ( elem.hasClass( 'playlist' ) ) { 1240 options.state = 'playlist'; 1241 options.title = wp.media.view.l10n.createPlaylistTitle; 1242 } else if ( elem.hasClass( 'video-playlist' ) ) { 1243 options.state = 'video-playlist'; 1244 options.title = wp.media.view.l10n.createVideoPlaylistTitle; 1245 } 1143 1246 1144 wp.media.editor.open( editor, options ); 1145 }); 1247 wp.media.editor.open( editor, options ); 1248 }) 1249 .on( 'click', '.wp-switch-editor', function () { 1250 var p; 1251 if ( window.mejs && window.mejs.players ) { 1252 for ( p in window.mejs.players ) { 1253 window.mejs.players[p].pause(); 1254 } 1255 } 1256 } ); 1146 1257 1147 1258 // Initialize and render the Editor drag-and-drop uploader. 1148 1259 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
6520 6520 */ 6521 6521 media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({ 6522 6522 initialize: function() { 6523 _.bindAll(this, 'success', 'unsetPlayer');6524 6525 6523 this.listenTo( this.controller, 'close', this.unsetPlayer ); 6526 6524 this.on( 'ready', this.setPlayer ); 6527 6525 this.on( 'media:setting:remove', this.unsetPlayer ); … … 6542 6540 }, this.options ); 6543 6541 }, 6544 6542 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 6543 removeSetting : function (e) { 6566 6544 var wrap = $( e.currentTarget ).parent(), setting; 6567 6545 … … 6599 6577 return this; 6600 6578 }, 6601 6579 6602 /**6603 * Override the MediaElement method for removing a player.6604 * MediaElement tries to pull the audio/video tag out of6605 * its container and re-add it to the DOM.6606 */6607 removePlayer: function() {6608 var t = this.player, featureIndex, feature;6609 6610 // invoke features cleanup6611 for ( featureIndex in t.options.features ) {6612 feature = t.options.features[featureIndex];6613 if ( t['clean' + feature] ) {6614 try {6615 t['clean' + feature](t);6616 } catch (e) {}6617 }6618 }6619 6620 if ( ! t.isDynamic ) {6621 t.$node.remove();6622 }6623 6624 if ( 'native' !== t.media.pluginType ) {6625 t.media.remove();6626 }6627 6628 delete window.mejs.players[t.id];6629 6630 t.container.remove();6631 t.globalUnbind();6632 delete t.node.player;6633 },6634 6635 unsetPlayer : function() {6636 if ( this.player ) {6637 if ( _.isUndefined( this.mejs.pluginType ) ) {6638 this.mejs.pause();6639 }6640 this.removePlayer();6641 this.player = false;6642 }6643 },6644 6645 6580 success : function (mejs) { 6646 6581 var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 6647 6582 … … 6675 6610 this.$( '.embed-media-settings' ).scrollTop( 0 ); 6676 6611 } 6677 6612 }, { 6678 instances : 0 6613 instances : 0, 6614 6615 /** 6616 * When multiple players in the DOM contain the same src, things get weird. 6617 * 6618 * @param {HTMLElement} media 6619 * @returns {HTMLElement} 6620 */ 6621 prepareSrc : function (media) { 6622 var i = wp.media.view.MediaDetails.instances++; 6623 if ( 0 === i ) { 6624 i = (new Date()).getTime(); 6625 } 6626 _.each( $(media).find('source'), function (source) { 6627 source.src = [ 6628 source.src, 6629 source.src.indexOf('?') > -1 ? '&' : '?', 6630 '_=', 6631 i 6632 ].join(''); 6633 }); 6634 6635 return media; 6636 } 6679 6637 }); 6638 _.extend( media.view.MediaDetails.prototype, media.mixin ); 6680 6639 6681 6640 /** 6682 6641 * wp.media.view.AudioDetails … … 6694 6653 template: media.template('audio-details'), 6695 6654 6696 6655 setMedia: function() { 6697 var audio = this.$('.wp-audio-shortcode'); 6656 var className = '.wp-audio-shortcode', 6657 audio; 6698 6658 6659 audio = this.$( className ); 6660 6699 6661 if ( audio.find( 'source' ).length ) { 6700 6662 if ( audio.is(':hidden') ) { 6701 6663 audio.show(); 6702 6664 } 6703 this.media = this.prepareSrc( audio.get(0) ); 6665 6666 audio = audio.get(0); 6667 6668 if ( $( className ).length > 0 ) { 6669 audio = media.view.MediaDetails.prepareSrc( audio ); 6670 } 6671 6672 this.media = audio; 6704 6673 } else { 6705 6674 audio.hide(); 6706 6675 this.media = false; … … 6726 6695 template: media.template('video-details'), 6727 6696 6728 6697 setMedia: function() { 6729 var video = this.$('.wp-video-shortcode'); 6698 var className = '.wp-video-shortcode', 6699 video, 6700 yt; 6730 6701 6702 video = this.$( className ); 6703 yt = video.hasClass('youtube-video'); 6704 6731 6705 if ( video.find( 'source' ).length ) { 6732 6706 if ( video.is(':hidden') ) { 6733 6707 video.show(); 6734 6708 } 6735 6709 6736 if ( ! video.hasClass('youtube-video') ) {6737 this.media = this.prepareSrc( video.get(0) ); 6738 } else{6739 this.media = video.get(0);6710 video = video.get(0); 6711 6712 if ( ! yt ) { 6713 video = media.view.MediaDetails.prepareSrc( video ); 6740 6714 } 6715 6716 this.media = video; 6741 6717 } else { 6742 6718 video.hide(); 6743 6719 this.media = false; -
src/wp-includes/js/mediaelement/wp-mediaelement.css
1 1 .mejs-container, .mejs-embed, .mejs-embed body { 2 background: # 464646;2 background: #000; 3 3 } 4 4 5 5 .mejs-controls .mejs-time-rail .mejs-time-loaded { -
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
235 235 } 236 236 237 237 /** 238 * Gallery preview238 * Media previews 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 padding: 32px 0 0; 251 } 252 253 .wpview-type-video { 254 padding: 16px 0 0; 255 } 256 257 .wont-play { 258 padding: 8px 0; 259 } 260 261 .wont-play p { 262 display: block; 263 width: 80%; 264 margin: 0 5% 0 15%; 265 } 266 267 audio, 268 video, 269 embed { 270 display: -moz-inline-stack; 271 display: inline-block; 272 max-width: 100%; 273 } 274 275 .wpview-type-gallery:after { 248 276 content: ''; 249 277 display: block; 250 278 height: 0; … … 252 280 visibility: hidden; 253 281 } 254 282 255 283 .wpview-type-gallery.selected { 256 284 background-color: #efefef; 257 285 } 258 286 259 .wpview-type-gallery .toolbar { 287 .wpview-type-audio, 288 .wpview-type-video { 289 background-color: #efefef; 290 } 291 292 .wpview-type-gallery .toolbar, 293 .wpview-type-audio .toolbar, 294 .wpview-type-video .toolbar { 260 295 position: absolute; 261 296 top: 0; 262 297 left: 0; … … 264 299 color: white; 265 300 padding: 4px; 266 301 display: none; 302 z-index: 100; 267 303 } 268 304 305 .wpview-type-audio .toolbar, 306 .wpview-type-video .toolbar { 307 display: block; 308 } 309 269 310 .wpview-type-gallery.selected .toolbar { 270 311 display: block; 271 312 } 272 313 273 .wpview-type-gallery .toolbar span { 314 .wpview-type-gallery .toolbar span, 315 .wpview-type-audio .toolbar span 316 .wpview-type-video .toolbar span { 274 317 cursor: pointer; 275 318 } 276 319 -
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 <div style="max-width: 100%; width: {{ w }}px"> 61 <video controls 62 class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}" 63 width="{{ w }}" 64 height="{{ h }}" 65 <?php 66 $props = array( 'poster' => '', 'preload' => 'metadata' ); 67 foreach ( $props as $key => $value ): 68 if ( empty( $value ) ) { 69 ?><# 70 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) { 71 #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<# 72 } #> 73 <?php } else { 74 echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php 75 } 76 endforeach; 77 ?><# 78 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 79 ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 80 #> <?php echo $attr ?><# 81 } 82 <?php endforeach ?>#> 83 > 84 <# if ( ! _.isEmpty( data.model.src ) ) { 85 if ( isYouTube ) { #> 86 <source src="{{ data.model.src }}" type="video/youtube" /> 87 <# } else { #> 88 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 89 <# } 90 } #> 91 92 <?php foreach ( $video_types as $type ): 93 ?><# if ( data.model.<?php echo $type ?> ) { #> 94 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 95 <# } #> 96 <?php endforeach; ?> 97 {{{ data.model.content }}} 98 </video> 99 </div> 100 <?php 101 } 102 103 /** 11 104 * Prints the templates used in the media manager. 12 105 * 13 106 * @since 3.5.0 … … 676 769 <div class="media-embed media-embed-details"> 677 770 <div class="embed-media-settings embed-audio-settings"> 678 771 <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> 772 <?php wp_underscore_audio_template() ?> 699 773 <# if ( ! _.isEmpty( data.model.src ) ) { #> 700 774 <label class="setting"> 701 775 <span>SRC</span> … … 738 812 </div> 739 813 </script> 740 814 815 <script type="text/html" id="tmpl-editor-audio"> 816 <div class="toolbar"> 817 <div class="dashicons dashicons-format-audio edit"></div> 818 <div class="dashicons dashicons-no-alt remove"></div> 819 </div> 820 <?php wp_underscore_audio_template() ?> 821 </script> 822 741 823 <script type="text/html" id="tmpl-video-details"> 742 824 <?php $video_types = wp_get_video_extensions(); ?> 743 825 <div class="media-embed media-embed-details"> … … 744 826 <div class="embed-media-settings embed-video-settings"> 745 827 <div class="instructions media-instructions">{{{ wp.media.view.l10n.videoDetailsText }}}</div> 746 828 <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> 829 <?php wp_underscore_video_template() ?> 795 830 <# if ( ! _.isEmpty( data.model.src ) ) { #> 796 831 <label class="setting"> 797 832 <span>SRC</span> … … 857 892 </div> 858 893 </div> 859 894 </script> 895 896 <script type="text/html" id="tmpl-editor-video"> 897 <div class="toolbar"> 898 <div class="dashicons dashicons-format-video edit"></div> 899 <div class="dashicons dashicons-no-alt remove"></div> 900 </div> 901 <?php wp_underscore_video_template() ?> 902 </script> 860 903 <?php 861 904 862 905 //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