Make WordPress Core

Changeset 14624


Ignore:
Timestamp:
05/14/2010 06:48:47 AM (14 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-background.php

    r14617 r14624  
    155155<th scope="row"><?php _e('Current Background'); ?></th>
    156156<td>
    157 <style type="text/css">
    158 #custom-background-image {
    159     background-color: #<?php echo get_background_color()?>;
    160     <?php if ( get_background_image() ) { ?>
    161     background: url(<?php echo get_theme_mod('background_image_thumb', ''); ?>);
    162     background-repeat: <?php echo get_theme_mod('background_repeat', 'no-repeat'); ?>;
    163     background-position: top <?php echo get_theme_mod('background_position', 'left'); ?>;
    164     background-attachment: <?php echo get_theme_mod('background_position', 'fixed'); ?>;
    165     <?php } ?>
     157<?php
     158$background_styles = "background-color: #" . get_background_color() . ";";
     159
     160if ( get_background_image() ) {
     161    $background_styles .= "
     162    background-image: url(" . get_theme_mod('background_image_thumb', '') . ");
     163    background-repeat: ". get_theme_mod('background_repeat', 'no-repeat') . ";
     164    background-position: top ". get_theme_mod('background_position', 'left') . ";
     165    background-attachment: " . get_theme_mod('background_position', 'fixed') . ";
     166    ";
    166167}
    167 </style>
    168 <div id="custom-background-image">
     168?>
     169<div id="custom-background-image" style="<?php echo $background_styles; ?>">
    169170<?php if ( get_background_image() ) { ?>
    170171<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /><br />
     
    326327        $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
    327328        set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) );
     329       
     330        set_theme_mod('background_position', get_theme_mod('background_position', 'left') );
     331        set_theme_mod('background_repeat', get_theme_mod('background_repeat', 'tile') );
     332        set_theme_mod('background-attachment',  get_theme_mod('background_position', 'fixed') );
    328333
    329334        do_action('wp_create_file_in_uploads', $file, $id); // For replication
Note: See TracChangeset for help on using the changeset viewer.