Here is my function:
function insert_img_rel_attrib( $html, $id, $caption, $title, $align, $url )
{
$postID = ???
$rel = "<a rel='shadowbox[".$postID."]'";
if ($url) {$html = str_replace("<a",$rel,$html);}
return $html;
}
add_filter( 'image_send_to_editor', 'insert_img_rel_attrib', 10, 6 );
How do I get the current post ID? I’ve tried the obvious, global $wp_query;
etc.
$postID = $wp_query->post->ID;
This should work within your function:
Your global should work, what happens when you echo
$postID
( you should probably use a more unique name here).You can also try,
I am not very familiar with this hook though, you might have to use
wpdb
.From what I recall, the global
$post
isn’t set in the thickbox. You can check the contents of the global$_REQUEST
though, and retrieve it from there (assuming that the editor is being called from a post editing screen and not through the media manager or some other location).