Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#29215 closed feature request (fixed)


Reported by: celloexpressions's profile celloexpressions Owned by: ocean90's profile ocean90
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.5
Component: Customize Keywords: has-patch needs-testing
Focuses: Cc:


We'd like to refactor the existing WP_Customize_Upload_Control, WP_Customize_Image_Control, and WP_Customize_Background_Image_Control to leverage the media library (#21483). But the Customizer should also support inserting media (including things like Youtube videos) from a URL, for which "Upload" isn't the best term.

We should introduce a WP_Customize_Media_Control to serve as the base media-related control that all of the other media image/upload controls extend (or, if we can't be fully back-compat, we could create new controls that extend this one). It should allow developers to specify either a media type (ie, audio, video, image, document, etc; mapping to allowed filetypes and embed providers) or potentially specific filetypes (like WP_Customize_Upload_Control allows now).

Ultimately, the purpose of this control will be to bring the full power of the media manager into the Customizer.

Attachments (3)

29215.diff (9.1 KB) - added by celloexpressions 9 years ago.
Implement WP_Customize_Media_Control.
29215.patch (10.1 KB) - added by ocean90 9 years ago.
29215.2.patch (10.9 KB) - added by ocean90 9 years ago.
@since 4.2.0 Moved from WP_Customize_Upload_Control.

Download all attachments as: .zip

Change History (15)

#1 @celloexpressions
9 years ago

After some discussions at WCLA Contributor Day, the thought is that WP_Customize_Media_Control could be a distinct control from the upload/image controls that does what we can't do there because of back-compatibility. The other controls will be updated to leverage the media manager, but we won't be able to leverage any of the other attachment info besides the image URL.

WP_Customize_Media_Control, on the other hand, could store more detailed/structured information in its settings. Potentially, we could store what we would normally put in the_content here and apply filters to get_option/theme_mod to render any media shortcodes, external embeds, images with captions and lt tags, etc.

#2 follow-up: @nacin
9 years ago

Can I ask who "we" is? :-)

#3 in reply to: ↑ 2 @celloexpressions
9 years ago

Replying to nacin:

Can I ask who "we" is? :-)

I think pretty much everyone was in favor of doing what #21483 did :)

#4 @celloexpressions
9 years ago

#27118 was marked as a duplicate.

This ticket was mentioned in Slack in #core by ocean90. View the logs.

9 years ago

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.

9 years ago

9 years ago

Implement WP_Customize_Media_Control.

#7 @celloexpressions
9 years ago

  • Keywords has-patch needs-testing added; needs-patch removed
  • Milestone changed from Future Release to 4.2

29215.diff implements a new base class for all Customizer media controls: WP_Customize_Media_Control. It's actually just the current WP_Customize_Upload_Control with things that are only there for back-compat (from 4.1) pulled out and with a couple of key changes so that it used settings that store attachment ids instead of URLs. WP_Customize_Upload_Control is then subclassed from the new media control, and contains the extracted back-compat and adjustments to make associated settings store URLs instead of attachment ids. There are no functional changes to the upload control or any of its sub-controls.

We could theoretically create a whole tree of sub-controls directly under the media control like the upload control currently has. But WP_Customize_Image_Control is completely unnecessary now (just specify the mime_type arg as image in the upload or media control), so I don't think we should bother. Note that the default value of settings associated with WP_Customize_Media_Control is still a URL, since it wouldn't make sense to support attachment ids here.

The CSS changes here are obviously absurd, see #30713 and #30618.

I think we should probably retain the existing @since values in what is now WP_Customize_Media_Control rather than changing them all to 4.2, but could see it making sense to change them.

#8 @celloexpressions
9 years ago

Patched #30713, so we won't need to worry about the CSS class inflation once that goes in (either this or that can go in first, but the other will need a refresh).

Also, re-reading the ticket description, insert-from-URL still isn't in scope here, since that's easy enough to handle in a text field control or a custom control that implements previewing inline. The biggest issue with the existing media controls is the way the data is stored, and this solves that.

This ticket was mentioned in Slack in #core by drew. View the logs.

9 years ago

#10 @celloexpressions
9 years ago

Still waiting for feedback or commit. I don't see any issues with this going into 4.2 but we're low on time if anyone does find issues.

9 years ago


9 years ago

@since 4.2.0 Moved from WP_Customize_Upload_Control.

#11 @ocean90
9 years ago

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

In 31698:

Customizer: Introduce WP_Customize_Media_Control.

WP_Customize_Media_Control is a new base class for all Customizer media controls. If used directly it supports the ID of an attachment instead of an URL like WP_Customize_Upload_Control.

props celloexpressions.
fixes #29215.

This ticket was mentioned in Slack in #core-customize by scofennell. View the logs.

8 years ago

Note: See TracTickets for help on using tickets.