The media_send_to_editor
filter allows you to modify the HTML attachment markup sent to the editor when inserting media.
It is evaluated in:
wp_ajax_send_attachment_to_editor()
in the wp-admin/includes/ajax-actions.php filemedia_upload_form_handler()
in the wp-admin/includes/media.php file
media_send_to_editor
accepts 3 arguments:
- string
$html
The unslashed HTML to send to the editor. - int
$id
The attachment id. - array
$attachment
An array of attachment attributes.
Example:
The following allows you to disable inserting full-size images into the editor and instead inserts ‘large’ sized images.
View the code example on Gist.
Have a suggested improvement? You can fork the Gist and comment back with the link. If all is agreeable, I’ll merge in your changes. Crowd-sourced documentation FTW!