diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index cf953f007b..2fc8ebb302 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -1640,6 +1640,14 @@ function wp_ajax_upload_attachment() {
wp_die();
}
+ if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
+ if ( 'custom-background' === $post_data['context'] )
+ update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
+
+ if ( 'custom-header' === $post_data['context'] )
+ update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
+ }
+
$post = get_post( $attachment_id );
echo json_encode( array(
diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php
index 04c89166d4..9368da1b95 100644
--- a/wp-includes/class-wp-customize-control.php
+++ b/wp-includes/class-wp-customize-control.php
@@ -398,6 +398,52 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control {
+
+
+
+ __( 'Background Image' ),
+ 'section' => 'background_image',
+ 'context' => 'custom-background',
+ 'get_url' => 'get_background_image',
+ ) );
+
+ if ( $this->setting->default )
+ $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_background' ) );
+ }
+
+ public function tab_uploaded() {
+ $backgrounds = get_posts( array(
+ 'post_type' => 'attachment',
+ 'meta_key' => '_wp_attachment_is_custom_background',
+ 'meta_value' => $this->manager->get_stylesheet(),
+ 'orderby' => 'none',
+ 'nopaging' => true,
+ ) );
+
+ ?>print_tab_image( esc_url_raw( $background->guid ) );
+ }
+
+ public function tab_default_background() {
+ $this->print_tab_image( $this->setting->default );
+ }
}
class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
@@ -424,21 +470,15 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
?>
-
-
-
- print_tab_image( $header['url'], $header['thumbnail_url'] );
}
public function tab_default_headers() {
global $custom_image_header;
$custom_image_header->process_default_headers();
- foreach ( $custom_image_header->default_headers as $header ) : ?>
-
-
-
- default_headers as $header )
+ $this->print_tab_image( $header['url'], $header['thumbnail_url'] );
}
}
\ No newline at end of file
diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php
index 17357f4c97..8cf6d860b4 100644
--- a/wp-includes/class-wp-customize-manager.php
+++ b/wp-includes/class-wp-customize-manager.php
@@ -698,11 +698,7 @@ final class WP_Customize_Manager {
'theme_supports' => 'custom-background',
) );
- $this->add_control( new WP_Customize_Image_Control( $this, 'background_image', array(
- 'label' => __( 'Background Image' ),
- 'section' => 'background_image',
- 'context' => 'custom-background',
- ) ) );
+ $this->add_control( new WP_Customize_Background_Image_Control( $this ) );
$this->add_setting( 'background_repeat', array(
'default' => 'repeat',
diff --git a/wp-includes/js/customize-controls.dev.js b/wp-includes/js/customize-controls.dev.js
index d313d83174..bcd31323f2 100644
--- a/wp-includes/js/customize-controls.dev.js
+++ b/wp-includes/js/customize-controls.dev.js
@@ -158,6 +158,8 @@
if ( this.params.context )
control.uploader.param( 'post_data[context]', this.params.context );
+
+ control.uploader.param( 'post_data[theme]', api.settings.theme.stylesheet );
},
success: function( attachment ) {
this.setting.set( attachment.url );