WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 12 months ago

#18623 new feature request

Allow themes to pre-register multiple custom backgrounds

Reported by: zamoose Owned by:
Priority: normal Milestone: Awaiting Review
Component: Themes Version: 3.3
Severity: minor Keywords: needs-patch dev-feedback
Cc: travis@…, Marco_Teethgrinder, edward.caissie@…, obenland@…, sabreuse@…

Description

We currently have the ability to register multiple header images and to randomly cycle through them or allow users to select one and stick with it. Is there anything that would prevent a similar implementation for custom backgrounds?

Attachments (2)

custom-background.php-step-1.diff (15.8 KB) - added by kobenland 15 months ago.
Refactoring of custom-background.php. I'm just throwing it out there, Feedback more than welcome!
choose-background-images.diff (21.2 KB) - added by kobenland 15 months ago.
Makes uploaded background images reusable - like custom headers sans the randomness. Based on step-1.diff

Download all attachments as: .zip

Change History (14)

comment:1 zamoose22 months ago

  • Summary changed from Allow for themes to pre-register multiple custom backgrounds to Allow themes to pre-register multiple custom backgrounds

comment:2 wpsmith22 months ago

  • Cc travis@… added

comment:3 Marco_Teethgrinder22 months ago

  • Cc Marco_Teethgrinder added

comment:4 kawauso22 months ago

  • Keywords needs-patch added

comment:5 follow-up: nacin22 months ago

+1. Feature parity here would be great. Random backgrounds probably aren't a big headline feature though.

The way we allow for remove_theme_support('custom-header-uploads') would be a nice enhancement as well.

This will miss the boat for 3.3 without a patch soon.

comment:6 zamoose17 months ago

Any interest in trying to get this into 3.4? I'd love to see it there.

comment:7 cais15 months ago

  • Cc edward.caissie@… added

comment:8 in reply to: ↑ 5 kobenland15 months ago

  • Cc obenland@… added

Replying to nacin:

+1. Feature parity here would be great. Random backgrounds probably aren't a big headline feature though.

When you say feature parity, would that also include Themes registering their own background-images?

Would refactoring of /wp-admin/custom-background.php make sense as a first step?
I created a patch, where I took most of the stuff out of admin_page() and made it nice and clean with the Settings API. This way it would be easier to add more settings later.

comment:9 kobenland15 months ago

  • Keywords dev-feedback added

So I thought I might as well attach the patch and see how you guys like it.

The first diff:
I really didn't change functionality at all here. I just moved all the settings into callback functions for their settings fields functions. So it's just something I thought might help along.

As for the second diff:
I just added the possibility to choose from previously uploaded background images and refrained from supporting random backgrounds as that would add a lot of overhead and dublicate code.
Let me know if this is something that really needs to be patched, too.
This is what I did:

  • Changed the order of the settings to make it similar to the custom header screen:
    1. Preview
    2. Upload
    3. Image selection
    4. Remove button
    5. Reset button
    6. all the rest
  • Benefit would be less code (form markup, noces and nonce checking) and a more stringent user experience (as if I knew anthing about that)
  • Dublicated the CSS code to make the image selection behave like the custom header selection. It probably would be a good idea to merge selectors, but I didn't want to impose on merging the documented sections within the file.
  • get_uploaded_background_images() behaves a little bit different than get_uploaded_header_images(). It really uses thumnail information (URL, height, width).

I think that's all for now. Looking forward to feedback! :)

comment:10 zamoose15 months ago

Please issue your .diffs path-relative -- in other words, diff while in the root of your WP install, instead of from the root of your Mac.

kobenland15 months ago

Refactoring of custom-background.php. I'm just throwing it out there, Feedback more than welcome!

kobenland15 months ago

Makes uploaded background images reusable - like custom headers sans the randomness. Based on step-1.diff

comment:11 kobenland15 months ago

Updated. Thanks for your feedback!

comment:12 sabreuse12 months ago

  • Cc sabreuse@… added
Note: See TracTickets for help on using tickets.