function media_upload_flash_bypass() {
$browser_uploader = admin_url( 'media-new.php?browser-uploader' );
$browser_uploader .= '&post_id=' . (int) $post->ID;
} elseif ( ! empty( $GLOBALS['post_ID'] ) ) {
$browser_uploader .= '&post_id=' . (int) $GLOBALS['post_ID'];
<p class="upload-flash-bypass">
/* translators: 1: URL to browser uploader, 2: Additional link attributes. */
__( 'You are using the multi-file uploader. Problems? Try the <a href="%1$s" %2$s>browser uploader</a> instead.' ),
* Displays the browser's built-in uploader message.
function media_upload_html_bypass() {
<p class="upload-html-bypass hide-if-no-js">
<?php _e( 'You are using the browser’s built-in file uploader. The WordPress uploader includes multiple file selection and drag and drop capability. <a href="#">Switch to the multi-file uploader</a>.' ); ?>
* Used to display a "After a file has been uploaded..." help message.
function media_upload_text_after() {}
* Displays the checkbox to scale images.
function media_upload_max_image_resize() {
$checked = get_user_setting( 'upload_resize' ) ? ' checked="true"' : '';
if ( current_user_can( 'manage_options' ) ) {
$a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">';
<p class="hide-if-no-js"><label>
<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
/* translators: 1: Link start tag, 2: Link end tag, 3: Width, 4: Height. */
printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
* Displays the out of storage quota message in Multisite.
function multisite_over_quota_message() {
/* translators: %s: Allowed space allocation. */
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
size_format( get_space_allowed() * MB_IN_BYTES )
* Displays the image and editor in the post editor
* @param WP_Post $post A post object.
function edit_form_image_editor( $post ) {
$open = isset( $_GET['image-editor'] );
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
$attachment_id = (int) $post->ID;
$thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
$att_url = wp_get_attachment_url( $post->ID );
<div class="wp_attachment_holder wp-clearfix">
if ( wp_attachment_is_image( $post->ID ) ) :
if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
$nonce = wp_create_nonce( "image_editor-$post->ID" );
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
$open_style = ' style="display:none"';
$not_open_style = ' style="display:none"';
<div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
<div<?php echo $open_style; ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
<p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p>
<p><?php echo $image_edit_button; ?></p>
<div<?php echo $not_open_style; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
wp_image_editor( $attachment_id );
elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ) :
wp_maybe_generate_attachment_metadata( $post );
echo wp_audio_shortcode( array( 'src' => $att_url ) );
elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ) :
wp_maybe_generate_attachment_metadata( $post );
$meta = wp_get_attachment_metadata( $attachment_id );
$w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
$h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
if ( $h && $w < $meta['width'] ) {
$h = round( ( $meta['height'] * $w ) / $meta['width'] );
$attr = array( 'src' => $att_url );
if ( ! empty( $w ) && ! empty( $h ) ) {
$thumb_id = get_post_thumbnail_id( $attachment_id );
if ( ! empty( $thumb_id ) ) {
$attr['poster'] = wp_get_attachment_url( $thumb_id );
echo wp_video_shortcode( $attr );
elseif ( isset( $thumb_url[0] ) ) :
<div class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
<p id="thumbnail-head-<?php echo $attachment_id; ?>">
<img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" />
* Fires when an attachment type can't be rendered in the edit form.
* @param WP_Post $post A post object.
do_action( 'wp_edit_form_attachment_display', $post );
<div class="wp_attachment_details edit-form-section">
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
<p class="attachment-alt-text">
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php echo esc_attr( $alt_text ); ?>" />
<p class="attachment-alt-text-description" id="alt-text-description">
/* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
__( '<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ),
'target="_blank" rel="noopener"',
'<span class="screen-reader-text"> %s</span>',
/* translators: Accessibility text. */
__( '(opens in a new tab)' )
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
'textarea_name' => 'content',
'media_buttons' => false,
'quicktags' => $quicktags_settings,
<label for="attachment_content" class="attachment-content-description"><strong><?php _e( 'Description' ); ?></strong>
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
echo ': ' . __( 'Displayed on attachment pages.' );
<?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>
$extras = get_compat_media_markup( $post->ID );
echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
* Displays non-editable attachment metadata in the publish meta box.
function attachment_submitbox_metadata() {
$attachment_id = $post->ID;
$file = get_attached_file( $attachment_id );
$filename = esc_html( wp_basename( $file ) );
$meta = wp_get_attachment_metadata( $attachment_id );
if ( isset( $meta['width'], $meta['height'] ) ) {
$media_dims .= "<span id='media-dims-$attachment_id'>{$meta['width']} × {$meta['height']}</span> ";
/** This filter is documented in wp-admin/includes/media.php */
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
$att_url = wp_get_attachment_url( $attachment_id );
$author = new WP_User( $post->post_author );
$uploaded_by_name = __( '(no author)' );
if ( $author->exists() ) {
$uploaded_by_name = $author->display_name ? $author->display_name : $author->nickname;
$uploaded_by_link = get_edit_user_link( $author->ID );
<div class="misc-pub-section misc-pub-uploadedby">
<?php if ( $uploaded_by_link ) { ?>
<?php _e( 'Uploaded by:' ); ?> <a href="<?php echo $uploaded_by_link; ?>"><strong><?php echo $uploaded_by_name; ?></strong></a>
<?php _e( 'Uploaded by:' ); ?> <strong><?php echo $uploaded_by_name; ?></strong>
if ( $post->post_parent ) {
$post_parent = get_post( $post->post_parent );
$uploaded_to_title = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
$uploaded_to_link = get_edit_post_link( $post->post_parent, 'raw' );
<div class="misc-pub-section misc-pub-uploadedto">
<?php if ( $uploaded_to_link ) { ?>
<?php _e( 'Uploaded to:' ); ?> <a href="<?php echo $uploaded_to_link; ?>"><strong><?php echo $uploaded_to_title; ?></strong></a>
<?php _e( 'Uploaded to:' ); ?> <strong><?php echo $uploaded_to_title; ?></strong>
<div class="misc-pub-section misc-pub-attachment">
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" />
<span class="copy-to-clipboard-container">
<button type="button" class="button copy-attachment-url edit-media" data-clipboard-target="#attachment_url"><?php _e( 'Copy URL to clipboard' ); ?></button>
<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
<div class="misc-pub-section misc-pub-filename">
<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
<div class="misc-pub-section misc-pub-filetype">
<?php _e( 'File type:' ); ?>
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
echo esc_html( strtoupper( $matches[1] ) );
list( $mime_type ) = explode( '/', $post->post_mime_type );
if ( 'image' !== $mime_type && ! empty( $meta['mime_type'] ) ) {
if ( "$mime_type/" . strtolower( $matches[1] ) !== $meta['mime_type'] ) {
echo ' (' . $meta['mime_type'] . ')';
echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
if ( isset( $meta['filesize'] ) ) {
$file_size = $meta['filesize'];
} elseif ( file_exists( $file ) ) {
$file_size = filesize( $file );
if ( ! empty( $file_size ) ) {
<div class="misc-pub-section misc-pub-filesize">
<?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong>
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
'length_formatted' => __( 'Length:' ),
'bitrate' => __( 'Bitrate:' ),
* Filters the audio and video metadata fields to be shown in the publish meta box.
* The key for each item in the array should correspond to an attachment
* metadata key, and the value should be the desired label.
* @since 4.9.0 Added the `$post` parameter.
* @param array $fields An array of the attachment metadata keys and labels.
* @param WP_Post $post WP_Post object for the current attachment.
$fields = apply_filters( 'media_submitbox_misc_sections', $fields, $post );
foreach ( $fields as $key => $label ) {
if ( empty( $meta[ $key ] ) ) {
<div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
if ( ! empty( $meta['bitrate_mode'] ) ) {
echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
echo esc_html( $meta[ $key ] );
'dataformat' => __( 'Audio Format:' ),
'codec' => __( 'Audio Codec:' ),
* Filters the audio attachment metadata fields to be shown in the publish meta box.
* The key for each item in the array should correspond to an attachment
* metadata key, and the value should be the desired label.
* @since 4.9.0 Added the `$post` parameter.
* @param array $fields An array of the attachment metadata keys and labels.
* @param WP_Post $post WP_Post object for the current attachment.
$audio_fields = apply_filters( 'audio_submitbox_misc_sections', $fields, $post );
foreach ( $audio_fields as $key => $label ) {
if ( empty( $meta['audio'][ $key ] ) ) {
<div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
<?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
<div class="misc-pub-section misc-pub-dimensions">
<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
if ( ! empty( $meta['original_image'] ) ) {
<div class="misc-pub-section misc-pub-original-image">
<?php _e( 'Original image:' ); ?>
<a href="<?php echo esc_url( wp_get_original_image_url( $attachment_id ) ); ?>">
<?php echo esc_html( wp_basename( wp_get_original_image_path( $attachment_id ) ) ); ?>
* Parse ID3v2, ID3v1, and getID3 comments to extract usable data
* @param array $metadata An existing array with data
* @param array $data Data supplied by ID3 tags
function wp_add_id3_tag_data( &$metadata, $data ) {
foreach ( array( 'id3v2', 'id3v1' ) as $version ) {
if ( ! empty( $data[ $version ]['comments'] ) ) {
foreach ( $data[ $version ]['comments'] as $key => $list ) {
if ( 'length' !== $key && ! empty( $list ) ) {
$metadata[ $key ] = wp_kses_post( reset( $list ) );
// Fix bug in byte stream analysis.
if ( 'terms_of_use' === $key && 0 === strpos( $metadata[ $key ], 'yright notice.' ) ) {
$metadata[ $key ] = 'Cop' . $metadata[ $key ];