mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
git-svn-id: http://core.svn.wordpress.org/trunk@22496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4a008574d2
commit
87caf47c0f
@ -1009,7 +1009,7 @@ function post_thumbnail_meta_box( $post ) {
|
||||
$thumbnailId = $element.find('input[name="thumbnail_id"]'),
|
||||
title = '<?php _e( "Choose a Featured Image" ); ?>',
|
||||
update = '<?php _e( "Update Featured Image" ); ?>',
|
||||
frame, selection, setFeaturedImage;
|
||||
frame, setFeaturedImage;
|
||||
|
||||
setFeaturedImage = function( thumbnailId ) {
|
||||
$element.find('img').remove();
|
||||
@ -1020,21 +1020,23 @@ function post_thumbnail_meta_box( $post ) {
|
||||
$element.on( 'click', '.choose, img', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
if ( ! frame ) {
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
frame = wp.media({
|
||||
title: title,
|
||||
selection: [ wp.media.model.Attachment.get( $thumbnailId.val() ) ],
|
||||
library: {
|
||||
type: 'image'
|
||||
}
|
||||
});
|
||||
|
||||
frame.toolbar( new wp.media.view.Toolbar({
|
||||
controller: frame,
|
||||
items: {
|
||||
update: {
|
||||
style: 'primary',
|
||||
frame.toolbar.on( 'activate:select', function() {
|
||||
frame.toolbar.view().add({
|
||||
select: {
|
||||
text: update,
|
||||
priority: 40,
|
||||
|
||||
click: function() {
|
||||
var selection = frame.state().get('selection'),
|
||||
@ -1053,7 +1055,6 @@ function post_thumbnail_meta_box( $post ) {
|
||||
size = size || model.toJSON();
|
||||
|
||||
frame.close();
|
||||
selection.clear();
|
||||
|
||||
$( '<img />', {
|
||||
src: size.url,
|
||||
@ -1061,11 +1062,8 @@ function post_thumbnail_meta_box( $post ) {
|
||||
}).prependTo( $element );
|
||||
}
|
||||
}
|
||||
}
|
||||
}) );
|
||||
}
|
||||
|
||||
frame.open();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$element.on( 'click', '.remove', function( event ) {
|
||||
|
Loading…
Reference in New Issue
Block a user