Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#18041 closed defect (bug) (fixed)

Custom background preview doesn't show default background

Reported by: billerickson's profile billerickson Owned by: nacin's profile nacin
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.0
Component: Themes Keywords: has-patch early
Focuses: Cc:

Description

To replicate, in the Twenty Eleven theme I added this right after add_custom_background();

define( 'BACKGROUND_IMAGE', 'http://s.wordpress.org/style/images/wp3-logo.png' );

Viewing the site now shows the WordPress logo tiled across the background.

If you go to Appearance > Background, the Preview doesn't display the background image. If you upload another image, then click the "Restore Original Image" button, the preview stays empty but the actual background of the site displays the default image.

I've tried it with an absolute URL like above, absolute URL to image in the current WP install, and using get_bloginfo('url') or get_bloginfo('stylesheet_directory') to generate the proper URL.

When you View > Source of the admin page, this is what's showing up in the preview box:

<div id="custom-background-image" style=" background-image: url(''); background-repeat: repeat; background-position: top left"><img class="custom-background-image" src="" style="visibility:hidden;" alt="" /><br /> 
<img class="custom-background-image" src="" style="visibility:hidden;" alt="" /> 
</div> 

Attachments (3)

18041.patch (1.6 KB) - added by billerickson 13 years ago.
18041.2.patch (1.6 KB) - added by billerickson 13 years ago.
18041.3.patch (2.0 KB) - added by lancewillett 12 years ago.

Download all attachments as: .zip

Change History (12)

@billerickson
13 years ago

#1 @billerickson
13 years ago

  • Keywords has-patch dev-feedback added

The issue is that the Preview window uses the thumbnail generated when the image is uploaded. If you're using a default image (one not uploaded through WP), there is no thumbnail.

My patch checks to see if there's a thumbnail, and if there isn't it uses the image itself.

#2 @nacin
13 years ago

  • Keywords dev-feedback removed
  • Version changed from 3.2 to 3.0

Would have to check that it's proper behavior, but looks like a good start. So, get_theme_mod()'s second parameter is the default. We can simply do get_theme_mod( 'background_image_thumb', get_background_image() );

#3 @billerickson
13 years ago

Updated patch to just use get_background_image() as the second parameter.

#4 @wpsmith
13 years ago

  • Cc travis@… added

#5 @lancewillett
12 years ago

  • Cc lancewillett added

Ran into this today. I think better to add a new function get_background_image_thumb() to wp-includes/theme.php so the same code can be reused anywhere. I'll upload a patch.

#6 @SergeyBiryukov
12 years ago

  • Component changed from General to Themes

#7 @ryan
12 years ago

  • Keywords early added
  • Milestone changed from Awaiting Review to Future Release

#8 @nacin
12 years ago

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

In [20901]:

Preview by default the registered default image for custom backgrounds. props mfields, billerickson.

If there is a default color registered, show a 'Default' action rather than a 'Clear' action, as clearing the value would simply return to the default.

Make current_theme_supports() accept a second argument for 'custom-background' requests, the same as get_theme_support(). Missed in earlier changes, see #20249.

fixes #20734, fixes #18041.

#9 @nacin
12 years ago

  • Milestone changed from Future Release to 3.4
Note: See TracTickets for help on using tickets.