Use inline styles in custom background admin, and prepopulate background options. props jshreve, see #12186.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-14 06:48:47 +00:00
parent f00bc39c20
commit c5c6244c50

View File

@ -154,18 +154,19 @@ class Custom_Background {
<tr valign="top"> <tr valign="top">
<th scope="row"><?php _e('Current Background'); ?></th> <th scope="row"><?php _e('Current Background'); ?></th>
<td> <td>
<style type="text/css"> <?php
#custom-background-image { $background_styles = "background-color: #" . get_background_color() . ";";
background-color: #<?php echo get_background_color()?>;
<?php if ( get_background_image() ) { ?> if ( get_background_image() ) {
background: url(<?php echo get_theme_mod('background_image_thumb', ''); ?>); $background_styles .= "
background-repeat: <?php echo get_theme_mod('background_repeat', 'no-repeat'); ?>; background-image: url(" . get_theme_mod('background_image_thumb', '') . ");
background-position: top <?php echo get_theme_mod('background_position', 'left'); ?>; background-repeat: ". get_theme_mod('background_repeat', 'no-repeat') . ";
background-attachment: <?php echo get_theme_mod('background_position', 'fixed'); ?>; background-position: top ". get_theme_mod('background_position', 'left') . ";
<?php } ?> background-attachment: " . get_theme_mod('background_position', 'fixed') . ";
";
} }
</style> ?>
<div id="custom-background-image"> <div id="custom-background-image" style="<?php echo $background_styles; ?>">
<?php if ( get_background_image() ) { ?> <?php if ( get_background_image() ) { ?>
<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /><br /> <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /><br />
<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /> <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" />
@ -326,6 +327,10 @@ class Custom_Background {
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) ); set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) );
set_theme_mod('background_position', get_theme_mod('background_position', 'left') );
set_theme_mod('background_repeat', get_theme_mod('background_repeat', 'tile') );
set_theme_mod('background-attachment', get_theme_mod('background_position', 'fixed') );
do_action('wp_create_file_in_uploads', $file, $id); // For replication do_action('wp_create_file_in_uploads', $file, $id); // For replication
$this->updated = true; $this->updated = true;
} }