Media Controls

Media-related Customizer controls for handling file uploads, images, cropping, and specific image contexts.


WP_Customize_Media_Control

Base control for media selection using the WordPress media library.

Source: wp-includes/customize/class-wp-customize-media-control.php
Since: 4.2.0
Extends: WP_Customize_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'media'4.2.0Control type
$mime_typestringpublic''4.2.0Media control mime type
$button_labelsarraypublicarray()4.2.0Button labels, merged with defaults from get_default_button_labels()

Methods

MethodVisibilitySinceDescription
__construct( $manager, $id, $args )public4.1.0, 4.2.0 (moved)Merges $button_labels with defaults via get_default_button_labels().
enqueue()public3.4.0, 4.2.0 (moved)Enqueues wp_enqueue_media().
to_json()public3.4.0, 4.2.0 (moved)Exports label, mime_type, button_labels, canUpload, defaultAttachment, and attachment (via wp_prepare_attachment_for_js()).
render_content()public3.4.0, 4.2.0 (moved)No-op; content rendered via JS template.
content_template()public4.1.0, 4.2.0 (moved)Renders JS template with attachment preview (image/audio/video/document), remove/change/select buttons.
get_default_button_labels()public4.9.0Returns default button labels (select, change, default, remove, placeholder, frame_title, frame_button) based on mime type (video, audio, image, or default). Image type also includes site_icon label.

WP_Customize_Upload_Control

Upload control extending Media control. Resolves attachment from URL.

Source: wp-includes/customize/class-wp-customize-upload-control.php
Since: 3.4.0
Extends: WP_Customize_Media_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'upload'3.4.0Control type
$mime_typestringpublic''4.1.0Media control mime type
$button_labelsarraypublicarray()4.1.0Button labels
$removedstringpublic''Unused property
$contextmixedpublicUnused property
$extensionsarraypublicarray()Unused property

Methods

MethodVisibilitySinceDescription
to_json()public3.4.0Calls parent, then resolves attachment ID from URL via attachment_url_to_postid() and adds attachment data via wp_prepare_attachment_for_js().

WP_Customize_Image_Control

Image-specific upload control.

Source: wp-includes/customize/class-wp-customize-image-control.php
Since: 3.4.0
Extends: WP_Customize_Upload_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'image'3.4.0Control type
$mime_typestringpublic'image'4.1.0Media control mime type

Methods

MethodVisibilitySinceDescription
prepare_control()public3.4.2Deprecated 4.1.0. No-op.
add_tab( $id, $label, $callback )public3.4.0Deprecated 4.1.0. No-op.
remove_tab( $id )public3.4.0Deprecated 4.1.0. No-op.
print_tab_image( $url, $thumbnail_url )public3.4.0Deprecated 4.1.0. No-op.

WP_Customize_Background_Image_Control

Control for the background image with theme support integration.

Source: wp-includes/customize/class-wp-customize-background-image-control.php
Since: 3.4.0
Extends: WP_Customize_Image_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'background'4.1.0Control type

Methods

MethodVisibilitySinceDescription
__construct( $manager )public3.4.0Hardcodes ID 'background_image', label 'Background Image', section 'background_image'.
enqueue()public4.1.0Calls parent enqueue, then localizes _wpCustomizeBackground with theme’s custom-background defaults and add nonce.

WP_Customize_Cropped_Image_Control

Control for images that require cropping to specific dimensions.

Source: wp-includes/customize/class-wp-customize-cropped-image-control.php
Since: 4.3.0
Extends: WP_Customize_Image_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'cropped_image'4.3.0Control type
$widthintpublic1504.3.0Suggested crop width
$heightintpublic1504.3.0Suggested crop height
$flex_widthboolpublicfalse4.3.0Whether width is flexible
$flex_heightboolpublicfalse4.3.0Whether height is flexible

Methods

MethodVisibilitySinceDescription
enqueue()public4.3.0Enqueues customize-views script, then calls parent.
to_json()public4.3.0Exports width, height, flex_width, flex_height (all as absint).

WP_Customize_Site_Icon_Control

Control for the site icon (favicon), with browser and app icon previews.

Source: wp-includes/customize/class-wp-customize-site-icon-control.php
Since: 4.3.0
Extends: WP_Customize_Cropped_Image_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'site_icon'4.3.0Control type

Methods

MethodVisibilitySinceDescription
__construct( $manager, $id, $args )public4.3.0Calls parent, adds wp_site_icon to customize_controls_print_styles at priority 99.
content_template()public4.5.0Renders JS template with app icon preview, browser tab preview (with SVG browser chrome), site title display, and upload/remove/change buttons.

WP_Customize_Header_Image_Control

Control for the header image with support for uploaded and default headers, randomization, and cropping.

Source: wp-includes/customize/class-wp-customize-header-image-control.php
Since: 3.4.0
Extends: WP_Customize_Image_Control

Properties

PropertyTypeVisibilityDefaultSinceDescription
$typestringpublic'header'4.2.0Control type
$uploaded_headersstringpublic3.9.0Uploaded header images
$default_headersstringpublic3.9.0Default header images

Methods

MethodVisibilitySinceDescription
__construct( $manager )public3.4.0Hardcodes ID 'header_image', settings ['default'=>'header_image', 'data'=>'header_image_data'], section 'header_image'.
enqueue()publicEnqueues media and customize-views. Calls prepare_control(). Localizes _wpCustomizeHeader with dimensions, flex settings, current image, nonces, uploads, and defaults.
prepare_control()publicProcesses default/uploaded headers via Custom_Image_Header. Adds print_header_image_template to footer scripts.
print_header_image_template()publicOutputs JS templates #tmpl-header-choice (with randomize and thumbnail buttons) and #tmpl-header-current.
get_current_image_src()publicReturns current header image source URL using the get_url callback.
render_content()publicRenders PHP content: instructions based on theme’s custom-header dimensions, current header display, hide/add image buttons, previously uploaded and suggested headers lists.