Image 如何从Wordpress 3.5上传中清除默认附件标题?
我想在上载新图像时清除图像标题中的默认“文件名”。我尝试使用下面的代码,但没有成功Image 如何从Wordpress 3.5上传中清除默认附件标题?,image,wordpress,attachment,uploader,wordpress-3.5,Image,Wordpress,Attachment,Uploader,Wordpress 3.5,我想在上载新图像时清除图像标题中的默认“文件名”。我尝试使用下面的代码,但没有成功 add_action( 'add_attachment', 'my_upload_title', 99 ); function my_upload_title( $attachment_ID ) { $the_post = array(); $the_post['ID'] = $attachment_ID; $the_post['post_t
add_action( 'add_attachment', 'my_upload_title', 99 );
function my_upload_title( $attachment_ID ) {
$the_post = array();
$the_post['ID'] = $attachment_ID;
$the_post['post_title'] = '';
wp_update_post( $the_post );
}
首先检查,或者您也可以尝试以下代码片段(将代码粘贴到functions.php
文件中)
感谢您的快速回复@Shiekh Heera!不幸的是,这两个答案在WP 3.5中似乎都不起作用。有趣的是,有一个“更新选项”功能用于图像对齐、链接类型和大小。
add_filter( 'wp_get_attachment_image_attributes', 'remove_image_text');
function remove_image_text( $attr ) {
unset($attr['alt']);
unset($attr['title']);
return $attr;
}