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;
}
#custom-background-image {
max-width: 400px;
max-height: 200px;
}
div#custom-background-image img {
max-width: 400px;
max-height: 200px;

View File

@ -227,15 +227,21 @@ class Custom_Background {
<div class="wrap" id="custom-background">
<?php screen_icon(); ?>
<h2><?php _e('Custom Background'); ?></h2>
<?php if ( get_background_image() ) { ?>
<p><?php _e('This is your current background image.'); ?></p>
<?php if ( get_background_image() || get_background_color() ) { ?>
<p><?php _e('This is your current background.'); ?></p>
<?php
if ( $this->admin_image_div_callback ) {
call_user_func($this->admin_image_div_callback);
} 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(); ?>" />
<?php } ?>
</div>
<?php }
} else { ?>

View File

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