Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Created May 18, 2019 17:23
Show Gist options
  • Save Asikur22/044979047be3323272f954e022b0f20d to your computer and use it in GitHub Desktop.
Save Asikur22/044979047be3323272f954e022b0f20d to your computer and use it in GitHub Desktop.
Add New Field To Attachment #Metabox #CustomMetabox
/*
* Show Image Id on Media Edit
*/
function ibenic_add_media_custom_field( $form_fields, $post ) {
$form_fields['info_ID'] = array(
'label' => __( 'Image ID' ),
'input' => 'html',
'html' => "<input type='text' class='text' readonly='readonly' onfocus='this.select();' value='" . esc_attr( $post->ID ) . "' /><br />",
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'ibenic_add_media_custom_field', null, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment