From 1d6fa49ae2342e3a42a91d03bdf9f8bd1d81b558 Mon Sep 17 00:00:00 2001
From: Daryl Koopersmith
@@ -800,7 +805,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) wp_die( __( 'Cheatin’ uh?' ) ); - + if ( $_POST['oitar'] > 1 ) { $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; diff --git a/wp-admin/js/custom-header.js b/wp-admin/js/custom-header.js index 05cc89a9e2..56fc7ec2e2 100644 --- a/wp-admin/js/custom-header.js +++ b/wp-admin/js/custom-header.js @@ -1,7 +1,9 @@ (function($) { - // Fetch available headers and apply jQuery.masonry - // once the images have loaded. + var frame; + $( function() { + // Fetch available headers and apply jQuery.masonry + // once the images have loaded. var $headers = $('.available-headers'); $headers.imagesLoaded( function() { @@ -9,5 +11,36 @@ 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().add({ + 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.state('library'); + }); }); }(jQuery));