Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_attachment_metadata ›

Seit2.1.0
Veraltetn/v
wp_get_attachment_metadata ( $attachment_id = 0, $unfiltered = false )
Parameter: (2)
  • (int) $attachment_id Attachment post ID. Defaults to global $post.
    Erforderlich: Nein
    Standard:
  • (bool) $unfiltered Optional. If true, filters are not run. Default false.
    Erforderlich: Nein
    Standard: false
Gibt zurück:
  • (mixed) Attachment meta field. False on failure.
Definiert in:
Codex:

Retrieve attachment meta field for attachment ID.



Quellcode

function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
	$attachment_id = (int) $attachment_id;
	$post          = get_post( $attachment_id );
	if ( ! $post ) {
		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 );
}