The get_upload_iframe_src() WordPress PHP function retrieves the upload iframe source URL.
Usage
get_upload_iframe_src( $type, $post_id, $tab );
Example:
Input:
get_upload_iframe_src( 'image', 1, 'library' );
Output:
https://example.com/wp-admin/media-upload.php?type=image&tab=library&post_id=1
Parameters
$type (string)
– Optional. Media type. Default: null$post_id (int)
– Optional. Post ID. Default: null$tab (string)
– Optional. Media upload tab. Default: null
More information
See WordPress Developer Resources: get_upload_iframe_src()
Examples
Default iframe source URL
Get the default media upload iframe source URL.
$iframe_src = get_upload_iframe_src(); echo $iframe_src; // Output: https://example.com/wp-admin/media-upload.php
Image type iframe source URL
Get the media upload iframe source URL for images.
$iframe_src = get_upload_iframe_src( 'image' ); echo $iframe_src; // Output: https://example.com/wp-admin/media-upload.php?type=image
Post ID specified iframe source URL
Get the media upload iframe source URL for a specific post.
$iframe_src = get_upload_iframe_src( 'image', 42 ); echo $iframe_src; // Output: https://example.com/wp-admin/media-upload.php?type=image&post_id=42
Media library tab iframe source URL
Get the media upload iframe source URL with the media library tab selected.
$iframe_src = get_upload_iframe_src( 'image', 42, 'library' ); echo $iframe_src; // Output: https://example.com/wp-admin/media-upload.php?type=image&tab=library&post_id=42
Video type iframe source URL
Get the media upload iframe source URL for videos.
$iframe_src = get_upload_iframe_src( 'video' ); echo $iframe_src; // Output: https://example.com/wp-admin/media-upload.php?type=video