image_attachment_fields_to_save()
云策文档标注
概述
image_attachment_fields_to_save() 是一个已弃用的 WordPress 函数,用于过滤媒体上传表单处理器的输入,并在未提供标题时从文件名分配默认标题。
关键要点
- 该函数已从 WordPress 6.0.0 版本起弃用,建议开发者避免使用。
- 它接受两个参数:$post(WP_Post 附件对象转换为数组)和 $attachment(附件元数据数组),并返回附件文章对象数组。
- 相关函数包括 _deprecated_function(),用于标记函数为弃用并通知使用情况。
代码示例
function image_attachment_fields_to_save( $post, $attachment ) {
_deprecated_function( __FUNCTION__, '6.0.0' );
return $post;
}注意事项
- 自 WordPress 6.0.0 起,此函数已被弃用,开发者应更新代码以使用替代方法。
- 函数最初在 WordPress 2.5.0 中引入,用于处理媒体上传时的标题分配。
原文内容
Was used to filter input from media_upload_form_handler() and to assign a default post_title from the file name if none supplied.
Parameters
$postarrayrequired-
The WP_Post attachment object converted to an array.
$attachmentarrayrequired-
An array of attachment metadata.
Source
function image_attachment_fields_to_save( $post, $attachment ) {
_deprecated_function( __FUNCTION__, '6.0.0' );
return $post;
}