wp_get_attachment_metadata
函数
wp_get_attachment_metadata ( $attachment_id = 0, $unfiltered = false )
- 参数
-
-
(int)
$attachment_id
Attachment post ID. Defaults to global $post.- Required: 否
-
(bool)
$unfiltered
Optional. If true, filters are not run. Default false.- Required: 否
- Default: false
-
(int)
- 返回值
-
- (array|false) { Attachment metadata. False on failure. @type int $width The width of the attachment. @type int $height The height of the attachment. @type string $file The file path relative to `wp-content/uploads`. @type array $sizes Keys are size slugs, each value is an array containing ‘file’, ‘width’, ‘height’, and ‘mime-type’. @type array $image_meta Image metadata. @type int $filesize File size of the attachment. }
- 定义位置
-
-
wp-includes/post.php
, line 6554
-
wp-includes/post.php
- 引入
- 2.1.0
- 弃用
- –
Retrieves attachment metadata for attachment ID.
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) { $attachment_id = (int) $attachment_id; if ( ! $attachment_id ) { $post = get_post(); if ( ! $post ) { return false; } $attachment_id = $post->ID; } $data = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); if ( ! $data ) { return false; } if ( $unfiltered ) { return $data; } /** * Filters the attachment meta data. * * @since 2.1.0 * * @param array $data Array of meta data for the given attachment. * @param int $attachment_id Attachment post ID. */ return apply_filters( 'wp_get_attachment_metadata', $data, $attachment_id ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。