检索附件ID的附件元字段。
原型
wp_get_attachment_metadata( int $attachment_id, bool $unfiltered = false )
参数
$attachment_id
(int)
(Required)
附件帖子ID。默认为全球$ post。
$unfiltered
(bool)
(Optional)
如果为true,则不运行过滤器。
返回值
(mixed)
附件元字段。失败时是假的。
源文件
路径:wp-includes/post.php
<?php
...
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
$attachment_id = (int) $attachment_id;
if ( ! $post = get_post( $attachment_id ) ) {
return false;
}
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
if ( $unfiltered )
return $data;
/**
* Filters the attachment meta data.
*
* @since 2.1.0
*
* @param array|bool $data Array of meta data for the given attachment, or false
* if the object does not exist.
* @param int $attachment_id Attachment post ID.
*/
return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_get_attachment_metadata/