When an HTML5 fallback button is pressed in the Audio or Video Details state, filter the library by that specific mime-type when the Add Audio|Video Source is activated.

See #27389.


Built from https://develop.svn.wordpress.org/trunk@27658


git-svn-id: http://core.svn.wordpress.org/trunk@27501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-03-23 03:16:14 +00:00
parent 38d1fb971f
commit 86f4061b26
5 changed files with 30 additions and 13 deletions

View File

@ -1408,8 +1408,9 @@
function init() { function init() {
$(document.body) $(document.body)
.on( 'click', '.wp-switch-editor', wp.media.mixin.pauseAllPlayers ) .on( 'click', '.wp-switch-editor', wp.media.mixin.pauseAllPlayers )
.on( 'click', '.add-media-source', function() { .on( 'click', '.add-media-source', function( e ) {
media.frame.setState('add-' + media.frame.defaults.id + '-source'); media.frame.lastMime = $( e.currentTarget ).data( 'mime' );
media.frame.setState( 'add-' + media.frame.defaults.id + '-source' );
} ); } );
} }

File diff suppressed because one or more lines are too long

View File

@ -1140,9 +1140,18 @@
initialize: function( options ) { initialize: function( options ) {
this.media = options.media; this.media = options.media;
this.set( 'library', media.query({ type: options.type }) ); this.type = options.type;
this.set( 'library', media.query({ type: this.type }) );
media.controller.Library.prototype.initialize.apply( this, arguments ); media.controller.Library.prototype.initialize.apply( this, arguments );
},
activate: function() {
if ( media.frame.lastMime ) {
this.set( 'library', media.query({ type: media.frame.lastMime }) );
delete media.frame.lastMime;
}
media.controller.Library.prototype.activate.apply( this, arguments );
} }
}); });

File diff suppressed because one or more lines are too long

View File

@ -771,7 +771,10 @@ function wp_print_media_templates() {
</script> </script>
<script type="text/html" id="tmpl-audio-details"> <script type="text/html" id="tmpl-audio-details">
<# var ext, html5types = { mp3: true, ogg: true }; #> <# var ext, html5types = {
mp3: wp.media.view.settings.embedMimes.mp3,
ogg: wp.media.view.settings.embedMimes.ogg
}; #>
<?php $audio_types = wp_get_audio_extensions(); ?> <?php $audio_types = wp_get_audio_extensions(); ?>
<div class="media-embed media-embed-details"> <div class="media-embed media-embed-details">
@ -810,8 +813,8 @@ function wp_print_media_templates() {
<div class="setting"> <div class="setting">
<span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span> <span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span>
<div class="button-large"> <div class="button-large">
<# _.each( html5types, function (value, type) { #> <# _.each( html5types, function (mime, type) { #>
<button class="button add-media-source">{{ type }}</button> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
<# } ) #> <# } ) #>
</div> </div>
</div> </div>
@ -847,7 +850,11 @@ function wp_print_media_templates() {
</script> </script>
<script type="text/html" id="tmpl-video-details"> <script type="text/html" id="tmpl-video-details">
<# var ext, html5types = { mp4: true, ogv: true, webm: true }; #> <# var ext, html5types = {
mp4: wp.media.view.settings.embedMimes.mp4,
ogv: wp.media.view.settings.embedMimes.ogv,
webm: wp.media.view.settings.embedMimes.webm
}; #>
<?php $video_types = wp_get_video_extensions(); ?> <?php $video_types = wp_get_video_extensions(); ?>
<div class="media-embed media-embed-details"> <div class="media-embed media-embed-details">
@ -896,8 +903,8 @@ function wp_print_media_templates() {
<div class="setting"> <div class="setting">
<span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span> <span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span>
<div class="button-large"> <div class="button-large">
<# _.each( html5types, function (value, type) { #> <# _.each( html5types, function (mime, type) { #>
<button class="button add-media-source">{{ type }}</button> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
<# } ) #> <# } ) #>
</div> </div>
</div> </div>