Make WordPress Core


Ignore:
Timestamp:
03/28/2010 02:53:04 AM (15 years ago)
Author:
dd32
Message:

Add Repeat-x/repeat-y support to Custom Backgrounds, Add Live preview of Repeat option, Use Thumbnail of background for Background Preview. Props jshreve. See #12186

File:
1 edited

Legend:

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

    r13830 r13856  
    9999
    100100        if ( isset($_POST['background-repeat']) ) {
    101             if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat')) )
     101            if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat', 'repeat-x', 'repeat-y')) )
    102102                $repeat = $_POST['background-repeat'];
    103103            else
     
    150150        call_user_func($this->admin_image_div_callback);
    151151    } else {
    152         if ( $bgcolor = get_background_color() )
    153             $bgcolor = 'background-color: #' . $bgcolor . ';';
    154 
    155         if ( $align = get_theme_mod('background_position', 'left') )
    156             $align = "text-align: $align;";
    157152?>
    158 <div id="custom-background-image"  style="<?php echo $bgcolor, $align ?>">
     153
     154<style type="text/css">
     155#custom-background-image {
     156    background-color: #<?php echo get_background_color()?>;
     157    <?php if ( get_background_image() ) { ?>
     158    background: url(<?php echo get_theme_mod('background_image_thumb', ''); ?>);
     159    background-repeat: <?php echo get_theme_mod('background_repeat', 'no-repeat'); ?>;
     160    background-position: top <?php echo get_theme_mod('background_position', 'left'); ?>;
     161    background-attachment: <?php echo get_theme_mod('background_position', 'fixed'); ?>;
     162    <?php } ?>
     163}
     164</style>
     165<div id="custom-background-image">
    159166<?php if ( get_background_image() ) { ?>
    160 <img class="custom-background-image" src="<?php background_image(); ?>" />
     167<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" /><br />
     168<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" />
    161169<?php } ?>
    162170<br class="clear" />
     
    193201<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Repeat' ); ?></span></legend>
    194202<label>
    195 <input name="background-repeat" type="radio" value="no-repeat" <?php checked('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?> />
    196 <?php _e('No repeat') ?>
    197 </label>
    198 <label>
    199 <input name="background-repeat" type="radio" value="repeat" <?php checked('repeat', get_theme_mod('background_repeat', 'repeat')); ?> />
    200 <?php _e('Tile') ?>
     203<select name="background-repeat">
     204    <option value="no-repeat" <?php selected('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?> ><?php _e('No repeat'); ?></option>
     205    <option value="repeat" <?php selected('repeat', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile'); ?></option>
     206    <option value="repeat-x" <?php selected('repeat-x', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Horizontally'); ?></option>
     207    <option value="repeat-y" <?php selected('repeat-y', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Vertically'); ?></option>
     208</select>
    201209</label>
    202210</fieldset></td>
     
    287295
    288296        set_theme_mod('background_image', esc_url($url));
     297
     298        $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
     299        set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) );
     300
    289301        do_action('wp_create_file_in_uploads', $file, $id); // For replication
    290302        $this->updated = true;
Note: See TracChangeset for help on using the changeset viewer.