Using WordPress ‘media_upload_type_url_form()’ PHP function

The media_upload_type_url_form WordPress PHP function outputs the legacy media upload form for external media.

Usage

media_upload_type_url_form( $type, $errors, $id )

Custom example:

media_upload_type_url_form( 'image', null, 1 );

This will output the legacy media upload form for external images with an ID of 1.

Parameters

  • $type (string) (Optional) – The media type, e.g., ‘image’, ‘audio’, ‘video’. Default: null
  • $errors (object) (Optional) – An object with errors, if any. Default: null
  • $id (int) (Optional) – The ID for the media item. Default: null

More information

See WordPress Developer Resources: media_upload_type_url_form

Examples

Display image upload form

This example displays the legacy media upload form for external images.

media_upload_type_url_form('image');

Display audio upload form with errors

This example displays the legacy media upload form for external audio with a custom error message.

$error = new WP_Error('error_code', 'Error message');
media_upload_type_url_form('audio', $error);

Display video upload form with ID

This example displays the legacy media upload form for external video with a specific ID.

media_upload_type_url_form('video', null, 123);

Display media upload form with a custom type

This example displays the legacy media upload form for a custom media type.

media_upload_type_url_form('custom_type');

Display image upload form with errors and ID

This example displays the legacy media upload form for external images with a custom error message and a specific ID.

$error = new WP_Error('error_code', 'Error message');
media_upload_type_url_form('image', $error, 456);