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

---

# media_send_to_editor( string $html )

## In this article

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

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

Adds image HTML to editor.

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

 `$html`stringrequired

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

    ```php
    function media_send_to_editor( $html ) {
    	?>
    	<script>
    	var win = window.dialogArguments || opener || parent || top;
    	win.send_to_editor( <?php echo wp_json_encode( $html, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
    	</script>
    	<?php
    	exit;
    }
    ```

[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#L273)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/media.php#L273-L281)

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

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

Encodes a variable into JSON, with some confidence checks.

  |

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

Handles form submissions for the legacy media uploader.

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

Handles the process of uploading media.

  |

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

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

## User Contributed Notes

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