mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +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"]'),
|
$thumbnailId = $element.find('input[name="thumbnail_id"]'),
|
||||||
title = '<?php _e( "Choose a Featured Image" ); ?>',
|
title = '<?php _e( "Choose a Featured Image" ); ?>',
|
||||||
update = '<?php _e( "Update Featured Image" ); ?>',
|
update = '<?php _e( "Update Featured Image" ); ?>',
|
||||||
frame, selection, setFeaturedImage;
|
frame, setFeaturedImage;
|
||||||
|
|
||||||
setFeaturedImage = function( thumbnailId ) {
|
setFeaturedImage = function( thumbnailId ) {
|
||||||
$element.find('img').remove();
|
$element.find('img').remove();
|
||||||
@ -1020,21 +1020,23 @@ function post_thumbnail_meta_box( $post ) {
|
|||||||
$element.on( 'click', '.choose, img', function( event ) {
|
$element.on( 'click', '.choose, img', function( event ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ( ! frame ) {
|
if ( frame ) {
|
||||||
|
frame.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frame = wp.media({
|
frame = wp.media({
|
||||||
title: title,
|
title: title,
|
||||||
|
selection: [ wp.media.model.Attachment.get( $thumbnailId.val() ) ],
|
||||||
library: {
|
library: {
|
||||||
type: 'image'
|
type: 'image'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frame.toolbar( new wp.media.view.Toolbar({
|
frame.toolbar.on( 'activate:select', function() {
|
||||||
controller: frame,
|
frame.toolbar.view().add({
|
||||||
items: {
|
select: {
|
||||||
update: {
|
|
||||||
style: 'primary',
|
|
||||||
text: update,
|
text: update,
|
||||||
priority: 40,
|
|
||||||
|
|
||||||
click: function() {
|
click: function() {
|
||||||
var selection = frame.state().get('selection'),
|
var selection = frame.state().get('selection'),
|
||||||
@ -1053,7 +1055,6 @@ function post_thumbnail_meta_box( $post ) {
|
|||||||
size = size || model.toJSON();
|
size = size || model.toJSON();
|
||||||
|
|
||||||
frame.close();
|
frame.close();
|
||||||
selection.clear();
|
|
||||||
|
|
||||||
$( '<img />', {
|
$( '<img />', {
|
||||||
src: size.url,
|
src: size.url,
|
||||||
@ -1061,11 +1062,8 @@ function post_thumbnail_meta_box( $post ) {
|
|||||||
}).prependTo( $element );
|
}).prependTo( $element );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}) );
|
});
|
||||||
}
|
|
||||||
|
|
||||||
frame.open();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$element.on( 'click', '.remove', function( event ) {
|
$element.on( 'click', '.remove', function( event ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user