diff --git wp-admin/custom-background.php wp-admin/custom-background.php
index dc19842..2ce3eee 100644
|
|
class Custom_Background { |
207 | 207 | set_theme_mod('background_position_x', $position); |
208 | 208 | } |
209 | 209 | |
| 210 | if ( isset($_POST['background-size']) ) { |
| 211 | check_admin_referer('custom-background'); |
| 212 | if ( in_array($_POST['background-size'], array('auto', 'cover', 'contain')) ) |
| 213 | $size = $_POST['background-size']; |
| 214 | else |
| 215 | $size = 'auto'; |
| 216 | set_theme_mod('background_size', $size); |
| 217 | } |
| 218 | |
210 | 219 | if ( isset($_POST['background-attachment']) ) { |
211 | 220 | check_admin_referer('custom-background'); |
212 | 221 | if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) ) |
… |
… |
class Custom_Background { |
265 | 274 | // Background-image URL must be single quote, see below. |
266 | 275 | $background_styles .= ' background-image: url(\'' . $background_image_thumb . '\');' |
267 | 276 | . ' background-repeat: ' . get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) . ';' |
268 | | . ' background-position: top ' . get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ); |
| 277 | . ' background-position: top ' . get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ) . ';' |
| 278 | . ' background-size: ' . get_theme_mod('background_size', get_theme_support('custom-background', 'default-size')) ; |
269 | 279 | } |
270 | 280 | ?> |
271 | 281 | <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?> |
… |
… |
class Custom_Background { |
361 | 371 | </tr> |
362 | 372 | |
363 | 373 | <tr> |
| 374 | <th scope="row"><?php _e( 'Size' ); ?></th> |
| 375 | <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Size' ); ?></span></legend> |
| 376 | <label><input type="radio" name="background-size" value="auto"<?php checked( 'auto', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?> /> <?php _e('Auto'); ?></label> |
| 377 | <label><input type="radio" name="background-size" value="cover"<?php checked( 'cover', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?> /> <?php _e('Cover'); ?></label> |
| 378 | <label><input type="radio" name="background-size" value="contain"<?php checked( 'contain', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?> /> <?php _e('Contain'); ?></label> |
| 379 | </fieldset></td> |
| 380 | </tr> |
| 381 | |
| 382 | <tr> |
364 | 383 | <th scope="row"><?php _ex( 'Attachment', 'Background Attachment' ); ?></th> |
365 | 384 | <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Attachment' ); ?></span></legend> |
366 | 385 | <label> |
diff --git wp-includes/class-wp-customize-manager.php wp-includes/class-wp-customize-manager.php
index c3a8273..e57a99d 100644
|
|
final class WP_Customize_Manager { |
1101 | 1101 | ), |
1102 | 1102 | ) ); |
1103 | 1103 | |
| 1104 | $this->add_setting( 'background_size', array( |
| 1105 | 'default' => get_theme_support( 'custom-background', 'default-size' ), |
| 1106 | 'theme_supports' => 'custom-background', |
| 1107 | ) ); |
| 1108 | |
| 1109 | $this->add_control( 'background_size', array( |
| 1110 | 'label' => __( 'Background Size' ), |
| 1111 | 'section' => 'background_image', |
| 1112 | 'type' => 'radio', |
| 1113 | 'choices' => array( |
| 1114 | 'auto' => __('Auto'), |
| 1115 | 'cover' => __('Cover'), |
| 1116 | 'contain' => __('Contain'), |
| 1117 | ), |
| 1118 | ) ); |
| 1119 | |
1104 | 1120 | $this->add_setting( 'background_position_x', array( |
1105 | 1121 | 'default' => get_theme_support( 'custom-background', 'default-position-x' ), |
1106 | 1122 | 'theme_supports' => 'custom-background', |
diff --git wp-includes/theme.php wp-includes/theme.php
index 038310d..c8db99e 100644
|
|
function _custom_background_cb() { |
1333 | 1333 | $position = 'left'; |
1334 | 1334 | $position = " background-position: top $position;"; |
1335 | 1335 | |
| 1336 | $size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size')); |
| 1337 | if ( ! in_array( $size, array('auto', 'cover', 'contain'))) |
| 1338 | $size = 'auto'; |
| 1339 | $size = " background-size: $size;"; |
| 1340 | |
1336 | 1341 | $attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ); |
1337 | 1342 | if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) |
1338 | 1343 | $attachment = 'scroll'; |
1339 | 1344 | $attachment = " background-attachment: $attachment;"; |
1340 | 1345 | |
1341 | | $style .= $image . $repeat . $position . $attachment; |
| 1346 | $style .= $image . $repeat . $position . $size . $attachment; |
1342 | 1347 | } |
1343 | 1348 | ?> |
1344 | 1349 | <style type="text/css" id="custom-background-css"> |
… |
… |
function add_theme_support( $feature ) { |
1582 | 1587 | 'default-image' => '', |
1583 | 1588 | 'default-repeat' => 'repeat', |
1584 | 1589 | 'default-position-x' => 'left', |
| 1590 | 'default-size' => 'auto', |
1585 | 1591 | 'default-attachment' => 'scroll', |
1586 | 1592 | 'default-color' => '', |
1587 | 1593 | 'wp-head-callback' => '_custom_background_cb', |