f88b538001
Most users don't realize that the Featured Image meta box exists; if they do, few use it. Restores the old meta box UI, including the admin_post_thumbnail_html filter. If a plugin is using _wp_post_thumbnail_html() in conjunction with Thickbox elsewhere, it will also magically still work. Specific underlying changes: * Converts the modal view to use the view manager, which means that a call to open() will automatically call render and attach if necessary. * Doesn't automatically set a state in wp.media, to allow code to customize the states to be added before activation. props koopersmith. fixes #21776. git-svn-id: https://develop.svn.wordpress.org/trunk@22979 602fd350-edb4-49c9-b593-d223f7449a82
47 lines
981 B
JavaScript
47 lines
981 B
JavaScript
(function($) {
|
|
var frame;
|
|
|
|
$( function() {
|
|
// Fetch available headers and apply jQuery.masonry
|
|
// once the images have loaded.
|
|
var $headers = $('.available-headers');
|
|
|
|
$headers.imagesLoaded( function() {
|
|
$headers.masonry({
|
|
itemSelector: '.default-header'
|
|
});
|
|
});
|
|
|
|
// Build the choose from library frame.
|
|
$('#choose-from-library-link').click( function( event ) {
|
|
var $el = $(this);
|
|
event.preventDefault();
|
|
|
|
frame = wp.media({
|
|
title: $el.data('choose'),
|
|
library: {
|
|
type: 'image'
|
|
}
|
|
});
|
|
|
|
frame.toolbar.on( 'activate:select', function() {
|
|
frame.toolbar.view().set({
|
|
select: {
|
|
style: 'primary',
|
|
text: $el.data('update'),
|
|
|
|
click: function() {
|
|
var attachment = frame.state().get('selection').first(),
|
|
link = $el.data('updateLink');
|
|
|
|
window.location = link + '&file=' + attachment.id;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
frame.setState('library').open();
|
|
});
|
|
});
|
|
}(jQuery));
|