WordPress.org

Make WordPress Core

Ticket #12186: inline_defaults_cb.diff

File inline_defaults_cb.diff, 2.2 KB (added by jshreve, 5 years ago)

inline style fix + bug fix where bg doesn't show initially

  • custom-background.php

     
    154154<tr valign="top"> 
    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 /> 
    171172<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /> 
     
    325326 
    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 
    330335                $this->updated = true;