Time To Modernize Custom Backgrounds In WordPress?

Josh Pollock - December 10, 2013

When was the last time that you used a tiled background image on a site, or saw one used and didn’t chuckle? If you wanted to use a tiled background for an ironic laugh WordPress’ custom background function has that as an option. What it doesn’t have is the ability to set a fixed position, full-screen background.

Since I prefer to not recreate core functionality in a theme I wanted, when I was working on the rewrite of my theme _Second Foundation to use the core custom backgrounds to handle the theme’s full-screen backgrounds. Unfortunately, there are no filters in _custom_background_cb(), the function in wp-includes/theme.php that outputs the CSS for the custom background.

I created a core ticket about this and wrote a patch to add full screen backgrounds as an option in custom backgrounds. It’s a start, but it has gotten me thinking about what else could be done to modernize the custom backgrounds feature? Besides fixed-position full-screen backgrounds, there are a lot of other possibilities. Here are some I thought of:

  • The ability to set backgrounds on specific containers in a post or on the whole post globally or on a per post basis.
    • This would probably be best accomplished via code>post_class()
  • Adding filters to override the CSS that core provides or override the setting.
    • This would mean that plugins or themes that do cool things with background images wouldn’t require separate settings. The background image wouldn’t need to be reset when plugin and themes are switched, making for a better end-user experience.
  • Get rid of the separate admin page for core backgrounds and use thecustomizer only.
    • Ticket #25569 makes a strong case for removing this redundancy. The customizer provides a much better UX then the custom backgrounds admin page does.
  • Use aJavascript instead of just pure CSS for backgrounds?
    • This is probably going too far, but jQuery Backstretch or some other plugin would allow for background slideshows and other cool things to be done.

I’m not sure how many of these ideas are worth doing. I’m also unsure if this is worth creating a feature as plugin project for or if it’s better served by just writing a few patches. It’s also possible I’m full of it, which happens from time to time. At this point I’m going to keep working on my patch when I have a chance. I’m throwing this out there to see if anyone is interested in sharing their opinion on this or writing some of the code.