Custom background color fixes. see #12186

git-svn-id: http://svn.automattic.com/wordpress/trunk@13668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-03-11 20:21:58 +00:00
parent 54bc1d84c2
commit 59873d0b4f
3 changed files with 33 additions and 7 deletions

View File

@ -3659,6 +3659,11 @@ div#custom-background h2 {
width:80px; width:80px;
} }
#custom-background-image {
max-width: 400px;
max-height: 200px;
}
div#custom-background-image img { div#custom-background-image img {
max-width: 400px; max-width: 400px;
max-height: 200px; max-height: 200px;

View File

@ -227,15 +227,21 @@ class Custom_Background {
<div class="wrap" id="custom-background"> <div class="wrap" id="custom-background">
<?php screen_icon(); ?> <?php screen_icon(); ?>
<h2><?php _e('Custom Background'); ?></h2> <h2><?php _e('Custom Background'); ?></h2>
<?php if ( get_background_image() ) { ?> <?php if ( get_background_image() || get_background_color() ) { ?>
<p><?php _e('This is your current background image.'); ?></p> <p><?php _e('This is your current background.'); ?></p>
<?php <?php
if ( $this->admin_image_div_callback ) { if ( $this->admin_image_div_callback ) {
call_user_func($this->admin_image_div_callback); call_user_func($this->admin_image_div_callback);
} else { } else {
if ( $bgcolor = get_background_color() )
$bgcolor = ' style="background-color: #' . $bgcolor . ';"';
else
$bgcolor = '';
?> ?>
<div id="custom-background-image" style="background-color: #<?php background_color(); ?>;"> <div id="custom-background-image"<?php echo $bgcolor; ?>>
<?php if ( get_background_image() ) { ?>
<img class="custom-background-image" src="<?php background_image(); ?>" /> <img class="custom-background-image" src="<?php background_image(); ?>" />
<?php } ?>
</div> </div>
<?php } <?php }
} else { ?> } else { ?>

View File

@ -1436,8 +1436,8 @@ function add_custom_background($header_callback = '', $admin_header_callback = '
*/ */
function _custom_background_cb() { function _custom_background_cb() {
$background = get_background_image(); $background = get_background_image();
$color = get_background_color();
if ( !$background ) if ( !$background && !$color )
return; return;
$repeat = get_theme_mod('background_repeat', 'repeat'); $repeat = get_theme_mod('background_repeat', 'repeat');
@ -1457,11 +1457,26 @@ function _custom_background_cb() {
$attachment = 'background-attachment: scroll;'; $attachment = 'background-attachment: scroll;';
else else
$attachment = 'background-attachment: fixed;'; $attachment = 'background-attachment: fixed;';
if ( !empty($background ) )
$image = "background-image: url('$background');";
else
$image = '';
if ( !empty($background ) )
$image = "background-image: url('$background');";
else
$image = '';
if ( !empty($color) )
$color = "background-color: #$color;";
else
$color = '';
?> ?>
<style type="text/css"> <style type="text/css">
body { body {
background-color: #<?php background_color(); ?>; <?php echo $image; ?>
background-image: url('<?php background_image(); ?>'); <?php echo $color; ?>
<?php echo $repeat; ?> <?php echo $repeat; ?>
<?php echo $position; ?> <?php echo $position; ?>
<?php echo $attachment; ?> <?php echo $attachment; ?>