A WordPress-centric search engine for devs and theme authors



wp_get_attachment_metadata ›

Since2.1.0
Deprecatedn/a
wp_get_attachment_metadata ( $post_id = 0, $unfiltered = false )
Parameters: (2)
  • (int) $post_id Attachment ID. Default 0.
    Required: No
    Default:
  • (bool) $unfiltered Optional. If true, filters are not run. Default false.
    Required: No
    Default: false
Returns:
  • (mixed) Attachment meta field. False on failure.
Defined at:
Codex:

Retrieve attachment meta field for attachment ID.



Source

function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
	$post_id = (int) $post_id;
	if ( !$post = get_post( $post_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        $post_id Attachment ID.
	 */
	return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
}