+/**
+ * Displays the out of storage quota message in Multisite.
+ *
+ * @since 3.5.0
+ */
+function multisite_over_quota_message() {
+ echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>';
+}
+
+/**
+ * Displays the image and editor in the post editor
+ *
+ * @since 3.5.0
+ */
+function edit_form_image_editor( $post ) {
+ $open = isset( $_GET['image-editor'] );
+ if ( $open )
+ require_once ABSPATH . 'wp-admin/includes/image-edit.php';
+
+ $thumb_url = false;
+ if ( $attachment_id = intval( $post->ID ) )
+ $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
+
+ $filename = esc_html( basename( $post->guid ) );
+ $title = esc_attr( $post->post_title );
+ $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">
+ <?php
+ if ( wp_attachment_is_image( $post->ID ) ) :
+ $image_edit_button = '';
+ 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>";
+ }
+ ?>
+
+ <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
+
+ <div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image" 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>
+ <div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
+ <?php if ( $open ) wp_image_editor( $attachment_id ); ?>
+ </div>
+ <?php
+ elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ):
+
+ echo wp_audio_shortcode( array( 'src' => $att_url ) );
+
+ elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
+
+ $meta = wp_get_attachment_metadata( $attachment_id );
+ $w = ! empty( $meta['width'] ) ? min( $meta['width'], 600 ) : 0;
+ $h = 0;
+ if ( ! empty( $meta['height'] ) )
+ $h = $meta['height'];
+ if ( $h && $w < $meta['width'] )
+ $h = round( ( $meta['height'] * $w ) / $meta['width'] );
+
+ $attr = array( 'src' => $att_url );
+
+ if ( ! empty( $meta['width' ] ) )
+ $attr['width'] = $w;
+
+ if ( ! empty( $meta['height'] ) )
+ $attr['height'] = $h;
+
+ echo wp_video_shortcode( $attr );
+
+ endif; ?>
+ </div>
+ <div class="wp_attachment_details edit-form-section">
+ <p>
+ <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>
+ </p>
+
+ <?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
+ <p>
+ <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" value="<?php echo esc_attr( $alt_text ); ?>" />
+ </p>
+ <?php endif; ?>
+
+ <?php
+ $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
+ $editor_args = array(
+ 'textarea_name' => 'content',
+ 'textarea_rows' => 5,
+ 'media_buttons' => false,
+ 'tinymce' => false,
+ 'quicktags' => $quicktags_settings,
+ );
+ ?>
+
+ <label for="content"><strong><?php _e( 'Description' ); ?></strong></label>
+ <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
+
+ </div>
+ <?php
+ $extras = get_compat_media_markup( $post->ID );
+ echo $extras['item'];
+ echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
+}
+
+/**
+ * Displays non-editable attachment metadata in the publish metabox
+ *
+ * @since 3.5.0
+ */
+function attachment_submitbox_metadata() {
+ $post = get_post();
+
+ $filename = esc_html( wp_basename( $post->guid ) );
+
+ $media_dims = '';
+ $meta = wp_get_attachment_metadata( $post->ID );
+ if ( isset( $meta['width'], $meta['height'] ) )
+ $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
+ $media_dims = apply_filters( 'media_meta', $media_dims, $post );
+
+ $att_url = wp_get_attachment_url( $post->ID );
+?>
+ <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" value="<?php echo esc_attr($att_url); ?>" />
+ </div>
+ <div class="misc-pub-section misc-pub-filename">
+ <?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
+ </div>
+ <div class="misc-pub-section misc-pub-filetype">
+ <?php _e( 'File type:' ); ?> <strong><?php
+ if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
+ echo esc_html( strtoupper( $matches[1] ) );
+ else
+ echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
+ ?></strong>
+ </div>
+
+ <?php
+ $file = get_attached_file( $post->ID );
+ $file_size = false;
+
+ 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>
+ </div>
+ <?php
+ endif;
+
+ if ( preg_match( '#^(audio|video)#', $post->post_mime_type ) ):
+
+ /**
+ * 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 3.7.0
+ *
+ * @param array $fields {
+ * An array of the attachment metadata keys and labels.
+ *
+ * @type string 'mime_type' Label to be shown before the field mime_type.
+ * @type string 'year' Label to be shown before the field year.
+ * @type string 'genre' Label to be shown before the field genre.
+ * @type string 'length_formatted' Label to be shown before the field length_formatted.
+ * }
+ */
+ $fields = apply_filters( 'media_submitbox_misc_sections', array(
+ 'mime_type' => __( 'Mime-type:' ),
+ 'year' => __( 'Year:' ),
+ 'genre' => __( 'Genre:' ),
+ 'length_formatted' => __( 'Length:' ),
+ ) );
+
+ 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 ); ?>">
+ <?php echo $label ?> <strong><?php echo esc_html( $meta[$key] ); ?></strong>
+ </div>
+ <?php
+ endif;
+ endforeach;
+
+ if ( ! empty( $meta['bitrate'] ) ) : ?>
+ <div class="misc-pub-section misc-pub-bitrate">
+ <?php _e( 'Bitrate:' ); ?> <strong><?php
+ echo round( $meta['bitrate'] / 1000 ), 'kb/s';
+
+ if ( ! empty( $meta['bitrate_mode'] ) )
+ echo ' ', strtoupper( $meta['bitrate_mode'] );
+
+ ?></strong>
+ </div>
+ <?php
+ endif;
+
+ /**
+ * 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 3.7.0
+ *
+ * @param array $fields {
+ * An array of the attachment metadata keys and labels.
+ *
+ * @type string 'dataformat' Label to be shown before the field dataformat.
+ * @type string 'codec' Label to be shown before the field codec.
+ * }
+ */
+ $audio_fields = apply_filters( 'audio_submitbox_misc_sections', array(
+ 'dataformat' => __( 'Audio Format:' ),
+ 'codec' => __( 'Audio Codec:' )
+ ) );
+
+ 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>
+ <?php
+ endif;
+ endforeach;
+
+ endif;
+
+ if ( $media_dims ) : ?>
+ <div class="misc-pub-section misc-pub-dimensions">
+ <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
+ </div>
+<?php
+ endif;
+}
+