I figured out the code if anyone is interested:
function be_attachment_field_credit( $form_fields, $post ) {
$form_fields['be-photographer-name'] = array(
'label' => 'Orientation',
'input' => 'html',
'value' => get_post_meta( $post->ID, 'be_photographer_name', true ),
'html' => "<input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op1'> Option 1  
<input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op2'> Option 2  
<input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op3'> Option 3",
);
$form_fields['be-photo-location'] = array(
'label' => 'Location',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'be_photo_location', true ),
'helps' => 'Where was this photo taken?',
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );
Now I am trying to work out this piece of code. I want to take the values from that radio button and use them as css classes for images inserted into my blog posts.
I have replaced the code that surrounds the attached images with this in my functions.php file:
function html5_insert_image($html, $id, $caption, $title, $align, $url) {
$url = wp_get_attachment_url($id);
$html5 = "<figure>";
$html5 .= "<img src='$url' alt='$title' />";
if ($caption) {
$html5 .= "<figcaption>$caption</figcaption>";
}
$html5 .= "</figure>";
return $html5;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );
I want to add the class to the <figure> element. I am messing around with this but having no luck:
$html5 = "<figure class='$attachment['be-photographer-name']';"
It gives me this error, Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING.
Any help would be awesome!