Add meta box to attachment

<?php

$hypbi_attachment_meta = new HypbiAttachmentMeta();

class HypbiAttachmentMeta{
public function __construct(){
add_filter('attachment_fields_to_edit',array($this,'add_image_meta_field'),null,2);
add_filter('attachment_fields_to_save',array($this,'save_image_meta_field'),null,2);
}
public function add_image_meta_field($form_fields,$post){
$form_fields['hypbi_option_code'] = array(
'label' => __('Build It Option Code'),
'value' => get_post_meta($post->ID,'_hypbi_option_code', true),
'helps' => __('Comma separated option code. For multiple options separate with pipe |'),
);
return $form_fields;
}
public function save_image_meta_field($post,$attachment){
if(isset($attachment['hypbi_option_code'])) update_post_meta($post['ID'],'_hypbi_option_code',$attachment['hypbi_option_code']);
return $post;
}
}

?>

Attatch Images

<?php

$args = array('post_type' => 'attachment','numberposts' => -1,'post_parent' => $post->ID);
$attachments = get_posts($args);
$current_post_thumbnail = get_post_thumbnail_id($id);

if($attachments){
foreach($attachments as $attachment){
if($attachment->ID == $current_post_thumbnail) continue;
echo wp_get_attachment_image($attachment->ID, 'thumbnail' );
break;
}
}
?>