Created
February 11, 2013 23:29
-
-
Save seamusleahy/4758617 to your computer and use it in GitHub Desktop.
Send additional header info for inserted media.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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