media_upload_form( array $errors = null )
- Since
- 2.5.0
- Source
wp-admin/includes/media.php:2092
Outputs the legacy media upload form.
Parameters
$errorsarrayoptional- Default:
null
Hooks fired · 10
10 hooks fire while media_upload_form() runs, in this order:
- do_action( upload_ui_over_quota )actionline 2141 (+49 into the body)
Fires when an upload will exceed the defined upload space quota for a network site.
- do_action( pre-upload-ui )actionline 2150 (+58 into the body)
Fires just before the legacy (pre-3.5.0) upload interface is loaded.
- apply_filters( upload_post_params )filterline 2168 (+76 into the body)
Filters the media upload post parameters.
- apply_filters( wp_prevent_unsupported_mime_type_uploads )filterline 2198 (+106 into the body)
Filter whether the server should prevent uploads for image types it doesn't support. Default true.
- apply_filters( plupload_init )filterline 2219 (+127 into the body)
Filters the default Plupload settings.
- do_action( pre-plupload-upload-ui )actionline 2250 (+158 into the body)
Fires before the upload interface loads.
- do_action( post-plupload-upload-ui )actionline 2267 (+175 into the body)
Fires after the upload interface loads.
- do_action( pre-html-upload-ui )actionline 2278 (+186 into the body)
Fires before the upload button in the media upload interface.
- do_action( post-html-upload-ui )actionline 2299 (+207 into the body)
Fires after the upload button in the media upload interface.
Uses · 23
- _device_can_upload()Tests if the current device has the capability to upload files.
- __()Retrieves the translation of $text.
- admin_url()Retrieves the URL to the admin area for the current site.
- wp_max_upload_size()Determines the maximum upload size allowed in php.ini.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- is_multisite()Determines whether Multisite is enabled.
- is_upload_space_available()Determines if there is any upload space left in the current blog's quota.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_is_mobile()Test if the current browser runs on a mobile device (smart phone, tablet, etc.).
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
Show all 23
- wp_image_editor_supports()Tests whether there is an editor that supports a given mime type or methods.
- absint()Converts a value to non-negative integer.
- get_option()Retrieves an option value based on an option name.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- _e()Displays translated text.
- _ex()Displays translated string with gettext context.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
- submit_button()Echoes a submit button, with provided text and appropriate class(es).
- _x()Retrieves translated string with gettext context.
- esc_html()Escaping for HTML blocks.
- size_format()Converts a number of bytes to the largest unit the bytes will fit into.
Used by · 1
- media_upload_type_form()Outputs the legacy media upload form for a given media type.
Source
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`,History
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-admin/includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.