How do I remove attachment fields, like description
and alt
in media library of Wordpress attachments?
The following code use to work on old Wo
The above solution by @brasofilo should work well, but we can also use this great answer by @EricAndrewLewis as a guideline on how to override the Backbone micro templates.
You can override the micro Backbone template #tmpl-attachment-details
with your custom #tmpl-attachment-details-custom
using:
wp.media.view.Attachment.Details.prototype.template = wp.media.template( 'attachment-details-custom' );
Similarly you can override the micro template #tmpl-attachment-details-two-column
with #tmpl-attachment-details-two-column-custom
using:
wp.media.view.Attachment.Details.TwoColumn.prototype.template = wp.media.template( 'attachment-details-two-column-custom' );
Here you can get the media templates used by the WordPress core.
1) The following code example should remove the Caption, Alt Text and Description fields from the Attachments Details template:
Screenshot:
Code:
/**
* Override the "Attachments Details" Backbone micro template in WordPress 4.0
*
* @see https://stackoverflow.com/a/25948448/2078474
*/
add_action( 'admin_footer-post.php', 'modified_attachments_details_template_so_25894288' );
function modified_attachments_details_template_so_25894288()
{?>
2) The following code example should remove the Caption, Alt Text and Description fields from the Attachments Details Two Column template:
Screenshot:
Code:
/**
* Override the "Attachments Details Two Column" Backbone micro template in WordPress 4.0
*
* @see https://stackoverflow.com/a/25948448/2078474
*/
add_action( 'admin_footer-upload.php', 'modified_attachments_details_two_column_template_so_25894288' );
function modified_attachments_details_two_column_template_so_25894288()
{ ?>
You can hopefully modify this to your needs.