Title: WP_Customize_Media_Control::content_template
Published: April 23, 2015
Last modified: May 20, 2026

---

# WP_Customize_Media_Control::content_template()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_media_control/content_template/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_media_control/content_template/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_media_control/content_template/?output_format=md#wp--skip-link--target)

Render a JS template for the content of the media control.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_media_control/content_template/?output_format=md#source)󠁿

    ```php
    public function content_template() {
    	?>
    	<#
    	var descriptionId = _.uniqueId( 'customize-media-control-description-' );
    	var describedByAttr = data.description ? ' aria-describedby="' + descriptionId + '" ' : '';
    	#>
    	<# if ( data.label ) { #>
    		<span class="customize-control-title">{{ data.label }}</span>
    	<# } #>
    	<div class="customize-control-notifications-container"></div>
    	<# if ( data.description ) { #>
    		<span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span>
    	<# } #>

    	<# if ( data.attachment && data.attachment.id ) { #>
    		<div class="attachment-media-view attachment-media-view-{{ data.attachment.type }} {{ data.attachment.orientation }}">
    			<div class="thumbnail thumbnail-{{ data.attachment.type }}">
    				<# if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.medium ) { #>
    					<img class="attachment-thumb" src="{{ data.attachment.sizes.medium.url }}" draggable="false" alt="" />
    				<# } else if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.full ) { #>
    					<img class="attachment-thumb" src="{{ data.attachment.sizes.full.url }}" draggable="false" alt="" />
    				<# } else if ( 'audio' === data.attachment.type ) { #>
    					<# if ( data.attachment.image && data.attachment.image.src && data.attachment.image.src !== data.attachment.icon ) { #>
    						<img src="{{ data.attachment.image.src }}" class="thumbnail" draggable="false" alt="" />
    					<# } else { #>
    						<img src="{{ data.attachment.icon }}" class="attachment-thumb type-icon" draggable="false" alt="" />
    					<# } #>
    					<p class="attachment-meta attachment-meta-title">&#8220;{{ data.attachment.title }}&#8221;</p>
    					<# if ( data.attachment.album || data.attachment.meta.album ) { #>
    					<p class="attachment-meta"><em>{{ data.attachment.album || data.attachment.meta.album }}</em></p>
    					<# } #>
    					<# if ( data.attachment.artist || data.attachment.meta.artist ) { #>
    					<p class="attachment-meta">{{ data.attachment.artist || data.attachment.meta.artist }}</p>
    					<# } #>
    					<audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
    						<source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}" />
    					</audio>
    				<# } else if ( 'video' === data.attachment.type ) { #>
    					<div class="wp-media-wrapper wp-video">
    						<video controls="controls" class="wp-video-shortcode" preload="metadata"
    							<# if ( data.attachment.image && data.attachment.image.src !== data.attachment.icon ) { #>poster="{{ data.attachment.image.src }}"<# } #>>
    							<source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}" />
    						</video>
    					</div>
    				<# } else { #>
    					<img class="attachment-thumb type-icon icon" src="{{ data.attachment.icon }}" draggable="false" alt="" />
    					<p class="attachment-title">{{ data.attachment.title }}</p>
    				<# } #>
    			</div>
    			<div class="actions">
    				<# if ( data.canUpload ) { #>
    				<button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
    				<button type="button" class="button upload-button control-focus" {{{ describedByAttr }}}>{{ data.button_labels.change }}</button>
    				<# } #>
    			</div>
    		</div>
    	<# } else { #>
    		<div class="attachment-media-view">
    			<# if ( data.canUpload ) { #>
    				<button type="button" class="upload-button button" {{{ describedByAttr }}}>{{ data.button_labels.select }}</button>
    			<# } #>
    			<div class="actions">
    				<# if ( data.defaultAttachment ) { #>
    					<button type="button" class="button default-button">{{ data.button_labels['default'] }}</button>
    				<# } #>
    			</div>
    		</div>
    	<# } #>
    	<?php
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-media-control.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/customize/class-wp-customize-media-control.php#L141)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/customize/class-wp-customize-media-control.php#L141-L210)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_media_control/content_template/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Moved from [WP_Customize_Upload_Control](https://developer.wordpress.org/reference/classes/wp_customize_upload_control/). | 
| [4.1.0](https://developer.wordpress.org/reference/since/4.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_media_control%2Fcontent_template%2F)
before being able to contribute a note or feedback.