wp_get_attachment_metadata() – Retrieves attachment metadata for attachment ID.
You appear to be a bot. Output may be restricted
Description
Retrieves attachment metadata for attachment ID.
Usage
$array|false = wp_get_attachment_metadata( $attachment_id, $unfiltered );
Parameters
- $attachment_id
- ( int ) optional – Attachment post ID. Defaults to global $post.
- $unfiltered
- ( bool ) optional – Optional. If true, filters are not run. Default false.
- $width
- ( int ) optional – The width of the attachment.
- $height
- ( int ) optional – The height of the attachment.
- $file
- ( string ) optional – The file path relative to `wp-content/uploads`.
- $sizes
- ( array ) optional – Keys are size slugs, each value is an array containing 'file', 'width', 'height', and 'mime-type'.
- $image_meta
- ( array ) optional – Image metadata.
- $filesize
- ( int ) optional – File size of the attachment. }
Returns
array|false { Attachment metadata. False on failure.
Source
File name: wordpress/wp-includes/post.php
Lines:
1 to 33 of 33
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 ); }