Skip to content

Instantly share code, notes, and snippets.

@seamusleahy
Created February 11, 2013 23:29
Show Gist options
  • Save seamusleahy/4758617 to your computer and use it in GitHub Desktop.
Save seamusleahy/4758617 to your computer and use it in GitHub Desktop.
Send additional header info for inserted media.
<?php
function send_extra_media_info( $html, $send_id, $attachment ) {
@header( "X-Attachment-ID: " . intval( $send_id ) );
foreach( array('post_title', 'image-size' ) as $key ) {
if( array_key_exists($key, $attachment) ) {
@header( "X-".$key.": " . str_replace( array( "\r", "\n"), ' ', $attachment[$key] ) );
}
}
return $html;
}
add_filter('media_send_to_editor', 'send_extra_media_info', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment