Title: wp_media_insert_url_form
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_media_insert_url_form( string $default_view = 'image' ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#wp--skip-link--target)

Creates the form for external url.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#parameters)󠁿

 `$default_view`stringoptional

Default:`'image'`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#return)󠁿

 string HTML content of the form.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#source)󠁿

    ```php
    function wp_media_insert_url_form( $default_view = 'image' ) {
    	/** This filter is documented in wp-admin/includes/media.php */
    	if ( ! apply_filters( 'disable_captions', '' ) ) {
    		$caption = '
    		<tr class="image-only">
    			<th scope="row" class="label">
    				<label for="caption"><span class="alignleft">' . __( 'Image Caption' ) . '</span></label>
    			</th>
    			<td class="field"><textarea id="caption" name="caption"></textarea></td>
    		</tr>';
    	} else {
    		$caption = '';
    	}

    	$default_align = get_option( 'image_default_align' );

    	if ( empty( $default_align ) ) {
    		$default_align = 'none';
    	}

    	if ( 'image' === $default_view ) {
    		$view        = 'image-only';
    		$table_class = '';
    	} else {
    		$view        = 'not-image';
    		$table_class = $view;
    	}

    	return '
    	<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> &nbsp; &nbsp; <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p>
    	<p class="media-types media-types-required-info">' .
    		wp_required_field_message() .
    	'</p>
    	<table class="describe ' . $table_class . '"><tbody>
    		<tr>
    			<th scope="row" class="label" style="width:130px;">
    				<label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> ' . wp_required_field_indicator() . '</label>
    				<span class="alignright" id="status_img"></span>
    			</th>
    			<td class="field"><input id="src" name="src" value="" type="text" required onblur="addExtImage.getImageData()" /></td>
    		</tr>

    		<tr>
    			<th scope="row" class="label">
    				<label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> ' . wp_required_field_indicator() . '</label>
    			</th>
    			<td class="field"><input id="title" name="title" value="" type="text" required /></td>
    		</tr>

    		<tr class="not-image"><td></td><td><p class="help">' . __( 'Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;' ) . '</p></td></tr>

    		<tr class="image-only">
    			<th scope="row" class="label">
    				<label for="alt"><span class="alignleft">' . __( 'Alternative Text' ) . '</span> ' . wp_required_field_indicator() . '</label>
    			</th>
    			<td class="field"><input id="alt" name="alt" value="" type="text" required />
    			<p class="help">' . __( 'Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;' ) . '</p></td>
    		</tr>
    		' . $caption . '
    		<tr class="align image-only">
    			<th scope="row" class="label"><p><label for="align">' . __( 'Alignment' ) . '</label></p></th>
    			<td class="field">
    				<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'none' === $default_align ? ' checked="checked"' : '' ) . ' />
    				<label for="align-none" class="align image-align-none-label">' . __( 'None' ) . '</label>
    				<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'left' === $default_align ? ' checked="checked"' : '' ) . ' />
    				<label for="align-left" class="align image-align-left-label">' . __( 'Left' ) . '</label>
    				<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'center' === $default_align ? ' checked="checked"' : '' ) . ' />
    				<label for="align-center" class="align image-align-center-label">' . __( 'Center' ) . '</label>
    				<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'right' === $default_align ? ' checked="checked"' : '' ) . ' />
    				<label for="align-right" class="align image-align-right-label">' . __( 'Right' ) . '</label>
    			</td>
    		</tr>

    		<tr class="image-only">
    			<th scope="row" class="label">
    				<label for="url"><span class="alignleft">' . __( 'Link Image To:' ) . '</span></label>
    			</th>
    			<td class="field"><input id="url" name="url" value="" type="text" /><br />

    			<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __( 'None' ) . '</button>
    			<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __( 'Link to image' ) . '</button>
    			<p class="help">' . __( 'Enter a link URL or click above for presets.' ) . '</p></td>
    		</tr>
    		<tr class="image-only">
    			<td></td>
    			<td>
    				<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__( 'Insert into Post' ) . '" />
    			</td>
    		</tr>
    		<tr class="not-image">
    			<td></td>
    			<td>
    				' . get_submit_button( __( 'Insert into Post' ), '', 'insertonlybutton', false ) . '
    			</td>
    		</tr>
    	</tbody></table>';
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/media.php#L2948)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/media.php#L2948-L3044)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#hooks)󠁿

 [apply_filters( ‘disable_captions’, bool $bool )](https://developer.wordpress.org/reference/hooks/disable_captions/)

Filters whether to disable captions.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_required_field_message()](https://developer.wordpress.org/reference/functions/wp_required_field_message/)`wp-includes/general-template.php` |

Creates a message to explain required form fields.

  | 
| [wp_required_field_indicator()](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/)`wp-includes/general-template.php` |

Assigns a visual indicator for required form fields.

  | 
| [get_submit_button()](https://developer.wordpress.org/reference/functions/get_submit_button/)`wp-admin/includes/template.php` |

Returns a submit button, with provided text and appropriate class.

  | 
| [esc_attr__()](https://developer.wordpress.org/reference/functions/esc_attr__/)`wp-includes/l10n.php` |

Retrieves the translation of $text and escapes it for safe use in an attribute.

  | 
| [checked()](https://developer.wordpress.org/reference/functions/checked/)`wp-includes/general-template.php` |

Outputs the HTML checked attribute.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#)

| Used by | Description | 
| [type_url_form_image()](https://developer.wordpress.org/reference/functions/type_url_form_image/)`wp-admin/includes/deprecated.php` |

Handles retrieving the insert-from-URL form for an image.

  | 
| [type_url_form_audio()](https://developer.wordpress.org/reference/functions/type_url_form_audio/)`wp-admin/includes/deprecated.php` |

Handles retrieving the insert-from-URL form for an audio file.

  | 
| [type_url_form_video()](https://developer.wordpress.org/reference/functions/type_url_form_video/)`wp-admin/includes/deprecated.php` |

Handles retrieving the insert-from-URL form for a video file.

  | 
| [type_url_form_file()](https://developer.wordpress.org/reference/functions/type_url_form_file/)`wp-admin/includes/deprecated.php` |

Handles retrieving the insert-from-URL form for a generic file.

  | 
| [media_upload_type_url_form()](https://developer.wordpress.org/reference/functions/media_upload_type_url_form/)`wp-admin/includes/media.php` |

Outputs the legacy media upload form for external media.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_media_insert_url_form%2F)
before being able to contribute a note or feedback.