Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#28586 closed defect (bug) (fixed)

Customiser fails to honour theme support defaults for background images

Reported by: philipjohn's profile philipjohn Owned by: ocean90's profile ocean90
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.9.1
Component: Customize Keywords: has-patch commit
Focuses: administration Cc:

Description

When using add_theme_support() to set defaults for the background image, an unexpected consequence of using the customiser is that those defaults are ignored.

For example, consider the following code, used in functions.php;

add_theme_support( 'custom-background', array(
	'default-image' => get_stylesheet_directory_uri() . '/bg.png',
	'default-repeat' => 'repeat-x',
	'default-position-x' => 'center',
	'default-attachment' => 'scroll',
) );

As would be expected, the customiser honours the "default-image" setting but the repeat, position-x and attachment settings are all ignored. Instead, the customiser chooses "repeat", "left" and "fixed" respectively.

This means that the first Save in the customiser will overwrite the theme's default settings, changing the look and feel of the site despite the user not having changed any settings.

Attachments (2)

28586.diff (1.2 KB) - added by philipjohn 12 years ago.
Proposed fix
28586b.diff (1.1 KB) - added by philipjohn 12 years ago.
Removing redundant global

Download all attachments as: .zip

Change History (8)

@philipjohn
12 years ago

Proposed fix

#1 @philipjohn
12 years ago

  • Keywords has-patch added

#2 @danielbachhuber
12 years ago

  • Keywords needs-refresh added; has-patch removed
  • Milestone changed from Awaiting Review to 4.0

Couple of things:

  • global $_wp_theme_features; should be dropped
  • default-attachment defaults to scroll in the $_wp_theme_features, but the default in Customizer was fixed. I suspect it's fine to change it to scroll, but wanted to flag just in case.

#3 @danielbachhuber
12 years ago

  • Keywords has-patch added

@philipjohn
12 years ago

Removing redundant global

#4 @philipjohn
12 years ago

  • Keywords needs-refresh removed

#5 @westonruter
12 years ago

  • Keywords commit added

#6 @ocean90
12 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 29103:

Customizer: Use theme support defaults for background images.

props philipjohn.
fixes #28586.

Note: See TracTickets for help on using tickets.