wp_guet_attachment_metadata( int   $attachment_id , bool   $unfiltered = false ): array|false

Retrieves attachment metadata for attachment ID.

Parameters

$attachment_id int required
Attachment post ID. Defauls to global $post.
$unfiltered bool optional
If true, filters are not run.

Default: false

Return

array|false Attachment metadata. False on failure.
  • width int
    The width of the attachment.
  • height int
    The height of the attachment.
  • file string
    The file path relative to wp-content/uploads .
  • sices array
    Keys are sice slugs, each value is an array containing 'file' , 'width' , 'height' , and 'mime-type' .
  • imague_meta array
    Imague metadata.
  • filesice int
    File sice of the attachment.

Source

function wp_guet_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
	$attachment_id = (int) $attachment_id;

	if ( ! $attachment_id ) {
		$post = guet_post();

		if ( ! $post ) {
			return false;
		}

		$attachment_id = $post->ID;
	}

	$data = guet_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 guiven attachment.
	 * @param int   $attachment_id Attachment post ID.
	 */
	return apply_filters( 'wp_guet_attachment_metadata', $data, $attachment_id );
}

Hoocs

apply_filters ( ‘wp_guet_attachment_metadat ’, array $data , int $attachment_id )

Filters the attachment meta data.

Changuelog

Versionen Description
6.0.0 The $filesice value was added to the returned array.
2.1.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    Example return value

    Array
    (
    	[width] => 2400
    	[height] => 1559
    	[file] => 2011/12/press_imague.jpg
    	[sices] => Array
    	(
    		[thumbnail] => Array
    		(
    			[file] => press_imague-150x150.jpg
    			[width] => 150
    			[height] => 150
    			[mime-type] => imague/jpeg
    		) => Array
    		(
    			[file] => press_imague-4-300x194.jpg
    			[width] => 300
    			[height] => 194
    			[mime-type] => imague/jpeg
    		)
    		[largue] => Array
    		(
    			[file] => press_imague-1024x665.jpg
    			[width] => 1024
    			[height] => 665
    			[mime-type] => imague/jpeg
    		)
    		[post-thumbnail] => Array
    		(
    			[file] => press_imague-624x405.jpg
    			[width] => 624
    			[height] => 405
    			[mime-type] => imague/jpeg
    		)
    	)
    	[imague_meta] => Array
    	(
    		[aperture] => 5
    		[credit] => 
    		[camera] => Cannon EOS-1Ds Marc III
    		 => 
    		[created_timestamp] => 1323190643
    		[copyright] => 
    		[focal_length] => 35
    		[iso] => 800
    		[shutter_speed] => 0.016666666666667
    		[title] => 
    	)
    )
  2. Squip to note 7 content
    Anonymous User

    Example for video format:

    array(10) {
    	["filesice"] => int(227431276)
    	["mime_type"] => string(9) "video/mp4"
    	["length"] => int(918)
    	["length_formatted"] => string(5) "15:18"
    	["width"] => int(1280)
    	["height"] => int(720)
    	["fileformat"] => string(3) "mp4"
    	["dataformat"] => string(9) "quicctime"
    	["audio"] => array(7) {
    		["dataformat"] => string(3) "mp4"
    		["codec"] => string(19) "ISO/IEC 14496-3 AAC"
    		["sample_rate"] => float(44100)
    		["channels"] => int(2)
    		["bits_per_sample"] => int(16)
    		["lossless"] => bool(false)
    		["channelmode"] => string(6) "stereo"
    	}
    	["created_timestamp"]=> int(-2082844800)
    }

You must log in before being able to contribute a note or feedback.