wp_media_insert_url_form

Creates the form for external url.

Description

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

Returns (string)

the form html

Parameters (1)

0. $default_view — Optional. (string) => 'image'
The default view.

Usage

  1. if ( !function_exists( 'wp_media_insert_url_form' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/media.php'; 
  3.  
  4. // The default view. 
  5. $default_view = 'image'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_media_insert_url_form($default_view); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/media.php  
  1. function wp_media_insert_url_form( $default_view = 'image' ) { 
  2. /** This filter is documented in wp-admin/includes/media.php */ 
  3. if ( ! apply_filters( 'disable_captions', '' ) ) { 
  4. $caption = ' 
  5. <tr class="image-only"> 
  6. <th scope="row" class="label"> 
  7. <label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label> 
  8. </th> 
  9. <td class="field"><textarea id="caption" name="caption"></textarea></td> 
  10. </tr> 
  11. '; 
  12. } else { 
  13. $caption = ''; 
  14.  
  15. $default_align = get_option('image_default_align'); 
  16. if ( empty($default_align) ) 
  17. $default_align = 'none'; 
  18.  
  19. if ( 'image' == $default_view ) { 
  20. $view = 'image-only'; 
  21. $table_class = ''; 
  22. } else { 
  23. $view = $table_class = 'not-image'; 
  24.  
  25. return ' 
  26. <p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label>     <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p> 
  27. <p class="media-types media-types-required-info">' . sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) . '</p> 
  28. <table class="describe ' . $table_class . '"><tbody> 
  29. <tr> 
  30. <th scope="row" class="label" style="width:130px;"> 
  31. <label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> <span class="required">*</span></label> 
  32. <span class="alignright" id="status_img"></span> 
  33. </th> 
  34. <td class="field"><input id="src" name="src" value="" type="text" required aria-required="true" onblur="addExtImage.getImageData()" /></td> 
  35. </tr> 
  36.  
  37. <tr> 
  38. <th scope="row" class="label"> 
  39. <label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> <span class="required">*</span></label> 
  40. </th> 
  41. <td class="field"><input id="title" name="title" value="" type="text" required aria-required="true" /></td> 
  42. </tr> 
  43.  
  44. <tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr> 
  45.  
  46. <tr class="image-only"> 
  47. <th scope="row" class="label"> 
  48. <label for="alt"><span class="alignleft">' . __('Alternative Text') . '</span></label> 
  49. </th> 
  50. <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" /> 
  51. <p class="help">' . __('Alt text for the image, e.g. “The Mona Lisa”') . '</p></td> 
  52. </tr> 
  53. ' . $caption . ' 
  54. <tr class="align image-only"> 
  55. <th scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th> 
  56. <td class="field"> 
  57. <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' /> 
  58. <label for="align-none" class="align image-align-none-label">' . __('None') . '</label> 
  59. <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' /> 
  60. <label for="align-left" class="align image-align-left-label">' . __('Left') . '</label> 
  61. <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' /> 
  62. <label for="align-center" class="align image-align-center-label">' . __('Center') . '</label> 
  63. <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' /> 
  64. <label for="align-right" class="align image-align-right-label">' . __('Right') . '</label> 
  65. </td> 
  66. </tr> 
  67.  
  68. <tr class="image-only"> 
  69. <th scope="row" class="label"> 
  70. <label for="url"><span class="alignleft">' . __('Link Image To:') . '</span></label> 
  71. </th> 
  72. <td class="field"><input id="url" name="url" value="" type="text" /><br /> 
  73.  
  74. <button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button> 
  75. <button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button> 
  76. <p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td> 
  77. </tr> 
  78. <tr class="image-only"> 
  79. <td></td> 
  80. <td> 
  81. <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" /> 
  82. </td> 
  83. </tr> 
  84. <tr class="not-image"> 
  85. <td></td> 
  86. <td> 
  87. ' . get_submit_button( __( 'Insert into Post' ), '', 'insertonlybutton', false ) . ' 
  88. </td> 
  89. </tr> 
  90. </tbody></table> 
  91. '; 
  92.