wppaste
WordPress

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

Since
2.7.0
Source
wp-admin/includes/media.php:2929
Creates the form for external url.

Compatibility

WordPress
since 2.7.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$default_viewstringoptional
Default: 'image'

Return value

string
HTML content of the form.

Performance profile

How much work a call to wp_media_insert_url_form() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Moderate

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
168–179

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 186.

Plugin surface
1 hook

Third-party callbacks on 'disable_captions' run inside this call, and their cost is not bounded by anything here.

Called by
5

5 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()called directly
  • cacheobject cachewp_cache_get()one call below wp_media_insert_url_form()
  • serializeserialisationmaybe_unserialize()one call below wp_media_insert_url_form()

Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_media_insert_url_form() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
apply_filters()168–174apply_filters(), get_option(), checked(), __(), checked(), __(), wp_required_field_message(), __(), wp_required_field_indicator(), __(), wp_required_field_indicator(), __(), __(), wp_required_field_indicator(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), esc_attr__(), __(), get_submit_button()
!apply_filters()173–179apply_filters(), __(), get_option(), checked(), __(), checked(), __(), wp_required_field_message(), __(), wp_required_field_indicator(), __(), wp_required_field_indicator(), __(), __(), wp_required_field_indicator(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), esc_attr__(), __(), get_submit_button()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 186 instructions, 168–179 executed per call, 7 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while wp_media_insert_url_form() runs, in this order:

  1. apply_filters( disable_captions )filterline 2931 (+2 into the body)

    Filters whether to disable captions.

Uses · 8

Used by · 5

Source code

<?phpfunction 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>

Changelog

Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.