WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 13 months ago

Last modified 13 months ago

#18041 closed defect (bug) (fixed)

Custom background preview doesn't show default background

Reported by: billerickson Owned by: nacin
Priority: normal Milestone: 3.4
Component: Themes Version: 3.0
Severity: normal Keywords: has-patch early
Cc: travis@…, lancewillett

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 2 years ago.
18041.2.patch (1.6 KB) - added by billerickson 2 years ago.
18041.3.patch (2.0 KB) - added by lancewillett 19 months ago.

Download all attachments as: .zip

Change History (12)

billerickson2 years ago

comment:1 billerickson2 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.

comment:2 nacin2 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() );

billerickson2 years ago

comment:3 billerickson2 years ago

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

comment:4 wpsmith23 months ago

  • Cc travis@… added

comment:5 lancewillett19 months 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.

lancewillett19 months ago

comment:6 SergeyBiryukov19 months ago

  • Component changed from General to Themes

comment:7 ryan19 months ago

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

comment:8 nacin13 months 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.

comment:9 nacin13 months ago

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