#34: $type_send_to_editor_url

The $type_send_to_editor_url filter allows you to modify the HTML markup sent to the editor when inserting non-image embed links into the editor.

The dynamic $type part of the filter hook accepts file, audio, or video.

Filtering image embed links sent to the editor is handled separately via the image_send_to_editor filter.

It is evaluated in:

$type_send_to_editor_url accepts 3 arguments:

  1. string $html The HTML link markup to send to the editor.
  2. string $url The media item source URL.
  3. string $title The media item title.

Example:

The following shows how you might add a data-type attribute (such as for JavaScript manipulation) to a video link when it is inserted into the editor.

View the code example on Gist.

#33: media_send_to_editor

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:

media_send_to_editor accepts 3 arguments:

  1. string $html The unslashed HTML to send to the editor.
  2. int $id The attachment id.
  3. 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.

#32: attachment_fields_to_save

The attachment_fields_to_save filter allows you to modify the associated data of an attachment.

It is evaluated in:

attachment_fields_to_save accepts 2 arguments:

  1. array $post The attachment attributes.
  2. array $attachment_data An array of attachment fields.

Example:

The following shows how you might go about saving a custom attachment field — we’ll say, a field with the id of image_editor_name — implemented via the attachment_fields_to_edit filter.

View the code example on Gist.