The media_upload_type_form WordPress PHP function outputs the legacy media upload form for a given media type.
Usage
media_upload_type_form($type = 'file', $errors = null, $id = null);
Parameters
- $type (string) Optional. Default: ‘file’. The media type to output the form for.
- $errors (array) Optional. Default: null. An array of error messages.
- $id (int|WP_Error) Optional. Default: null. The attachment ID or WP_Error object.
More information
See WordPress Developer Resources: media_upload_type_form
Examples
Display an image upload form
This example will display a form for uploading images.
media_upload_type_form('image');
Display an audio upload form
This example will display a form for uploading audio files.
media_upload_type_form('audio');
Display a video upload form
This example will display a form for uploading video files.
media_upload_type_form('video');
Display a form with custom error messages
This example will display a form for uploading images with custom error messages.
$errors = array( 'file_type' => 'Invalid file type. Please upload an image.', ); media_upload_type_form('image', $errors);
Display a form with an existing attachment ID
This example will display a form for uploading images with a pre-filled attachment ID.
$attachment_id = 123; media_upload_type_form('image', null, $attachment_id);