wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_get_attachment_metadata › WordPress Function

Od2.1.0
Przestarzałyn/a
wp_get_attachment_metadata ( $attachment_id = 0, $unfiltered = false )
Parametry: (2)
  • (int) $attachment_id Attachment post ID. Defaults to global $post.
    Wymagane: Nie
    Domyślny:
  • (bool) $unfiltered Optional. If true, filters are not run. Default false.
    Wymagane: Nie
    Domyślny: false
Powrót:
  • (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. }
Zdefiniowane na:
Codex:
Dziennik zmian:
  • 6.0.0

Retrieves attachment metadata for attachment ID.



Źródło

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 );
}