WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 months ago

#18623 new feature request

Allow themes to pre-register multiple custom backgrounds

Reported by: zamoose Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.3
Component: Appearance Keywords: dev-feedback has-patch
Focuses: Cc:

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 (6)

custom-background.php-step-1.diff (15.8 KB) - added by kobenland 2 years 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 2 years ago.
Makes uploaded background images reusable - like custom headers sans the randomness. Based on step-1.diff
18623.diff (29.4 KB) - added by obenland 4 months ago.
18623.2.diff (29.3 KB) - added by obenland 4 months ago.
18623.3.diff (32.1 KB) - added by obenland 4 months ago.
18623.4.diff (32.2 KB) - added by obenland 4 months ago.

Download all attachments as: .zip

Change History (36)

comment:1 zamoose3 years ago

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

comment:2 wpsmith3 years ago

  • Cc travis@… added

comment:3 Marco_Teethgrinder3 years ago

  • Cc Marco_Teethgrinder added

comment:4 kawauso3 years ago

  • Keywords needs-patch added

comment:5 follow-up: nacin3 years 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 zamoose2 years ago

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

comment:7 cais2 years ago

  • Cc edward.caissie@… added

comment:8 in reply to: ↑ 5 kobenland2 years 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 kobenland2 years 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 zamoose2 years 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.

kobenland2 years ago

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

kobenland2 years ago

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

comment:11 kobenland2 years ago

Updated. Thanks for your feedback!

comment:12 sabreuse22 months ago

  • Cc sabreuse@… added

comment:13 greenshady6 months ago

  • Cc justin@… added

comment:14 mercime6 months ago

  • Cc mercijavier@… added

comment:15 obenland5 months ago

#22348 was marked as a duplicate.

comment:16 dgwyer5 months ago

  • Cc d.v.gwyer@… added

comment:17 Frank Klein5 months ago

  • Cc contact@… added

obenland4 months ago

comment:18 obenland4 months ago

  • Keywords has-patch added; needs-patch removed

Maybe something for 3.9?

obenland4 months ago

obenland4 months ago

comment:19 ircbot4 months ago

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.

comment:20 jcastaneda4 months ago

  • Cc jomcastaneda@… added

obenland4 months ago

comment:22 SergeyBiryukov4 months ago

  • Component changed from Themes to Appearance

comment:23 ircbot3 months ago

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.

comment:24 ircbot3 months ago

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.

comment:25 follow-up: celloexpressions3 months ago

  • Focuses ui added

We need to make sure that any UI introduced here works with #21483 (which seems far more pressing). In fact, this might benefit from the entire custom header image interface moving to the media modal, which already supports selecting multiple images, if we create a backgrounds section of some sort. This could potentially allow users to select multiple default or custom images to use for backgrounds.

If this is addressed with (and fixes) #21483, we can hide the custom backgrounds page for most users (#25569), so we wouldn't need to worry about implementing a new interface twice or giving that page a much-needed refactoring. It makes a lot more sense for it to be in the media modal rather than in-page, but that would obviously work better for the customizer than the backgrounds page.

comment:26 in reply to: ↑ 25 obenland3 months ago

There is no new UI introduced in this ticket, it uses the existing UI from custom headers.

comment:27 helen3 months ago

  • Focuses ui removed

Removing the UI focus - obenland is correct in that those two UIs should probably match. If specific things are discovered later that need UI or turn this into a UI-heavy ticket (as opposed to API), then we can bring back the focus.

comment:28 celloexpressions3 months ago

Yes, the UIs should match. However, we should keep in mind that these UIs will most likely change in the (hopefully near) future, and need to change in order to fix usability issues such as the inability to select existing images from the customizer (and the odd implementation of that on the backgrounds page). I was suggesting that we might not want to put too much effort into things that are likely to be deprecated soon.

Anyway, I think I see what this ticket's trying to accomplish now, but it's not incredibly clear reading through everything (doesn't help that the discussion basically all took place before the customizer existed). Attachment descriptions tend to help too :)

comment:29 helen3 months ago

Just a gentle reminder that the customizer is only available with JS and we do support no-JS in most places. Since these pages exist and are functional, I would strongly prefer that they not just be ignored.

Again, happy to add UI focus back if/when UI is being worked on or is a central need for the ticket. I would just really like to actually be able to sanely manage the focus :)

comment:30 ircbot2 months ago

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.

Note: See TracTickets for help on using tickets.