media_upload_form() – Outputs the legacy media upload form.
You appear to be a bot. Output may be restricted
Description
Outputs the legacy media upload form.
Usage
media_upload_form( $errors );
Parameters
- $errors
- ( array ) optional –
Returns
void
Source
File name: wordpress/wp-admin/includes/media.php
Lines:
1 to 100 of 219
function media_upload_form( $errors = null ) { global $type, $tab; if ( ! _device_can_upload() ) { echo '<p>' . sprintf( /* translators: %s: https://apps.wordpress.org/ */ __( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ), 'https://apps.wordpress.org/' ) . '</p>'; return; } $upload_action_url = admin_url( 'async-upload.php' ); $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0; $_type = isset( $type ) ? $type : ''; $_tab = isset( $tab ) ? $tab : ''; $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { $max_upload_size = 0; } ?> <div id="media-upload-notice"> <?php if ( isset( $errors['upload_notice'] ) ) { echo $errors['upload_notice']; } ?> </div> <div id="media-upload-error"> <?php if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) { echo $errors['upload_error']->get_error_message(); } ?> </div> <?php if ( is_multisite() && ! is_upload_space_available() ) { /** * Fires when an upload will exceed the defined upload space quota for a network site. * * @since 3.5.0 */ do_action( 'upload_ui_over_quota' ); return; } /** * Fires just before the legacy (pre-3.5.0) upload interface is loaded. * * @since 2.6.0 */ do_action( 'pre-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores $post_params = array( 'post_id' => $post_id, '_wpnonce' => wp_create_nonce( 'media-form' ), 'type' => $_type, 'tab' => $_tab, 'short' => '1', ); /** * Filters the media upload post parameters. * * @since 3.1.0 As 'swfupload_post_params' * @since 3.3.0 * * @param array $post_params An array of media upload parameters used by Plupload. */ $post_params = apply_filters( 'upload_post_params', $post_params ); /* * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`, * and the `flash_swf_url` and `silverlight_xap_url` are not used. */ $plupload_init = array( 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'drag-drop-area', 'file_data_name' => 'async-upload', 'url' => $upload_action_url, 'filters' => array( 'max_file_size' => $max_upload_size . 'b' ), 'multipart_params' => $post_params, ); /* * Currently only iOS Safari supports multiple files uploading, * but iOS 7.x has a bug that prevents uploading of videos when enabled. * See #29602. */ if ( wp_is_mobile() && str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) &&