| @@ 617-635 (lines=19) @@ | ||
| 614 | * | |
| 615 | * @return (object) | |
| 616 | */ | |
| 617 | 	function get_attachment( $attachment ) { | |
| 618 | $metadata = wp_get_attachment_metadata( $attachment->ID ); | |
| 619 | ||
| 620 | $result = array( | |
| 621 | 'ID' => (int) $attachment->ID, | |
| 622 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), | |
| 623 | 'guid' => (string) $attachment->guid, | |
| 624 | 'mime_type' => (string) $attachment->post_mime_type, | |
| 625 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, | |
| 626 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, | |
| 627 | ); | |
| 628 | ||
| 629 | 		if ( isset( $metadata['duration'] ) ) { | |
| 630 | $result['duration'] = (int) $metadata['duration']; | |
| 631 | } | |
| 632 | ||
| 633 | return (object) apply_filters( 'get_attachment', $result ); | |
| 634 | } | |
| 635 | ||
| 636 | /** | |
| 637 | * Get post-specific user capabilities | |
| 638 | * @param WP_Post $post post object | |
| @@ 254-272 (lines=19) @@ | ||
| 251 | return $format; | |
| 252 | } | |
| 253 | ||
| 254 | 	private function get_attachment( $attachment ) { | |
| 255 | $metadata = wp_get_attachment_metadata( $attachment->ID ); | |
| 256 | ||
| 257 | $result = array( | |
| 258 | 'ID' => (int) $attachment->ID, | |
| 259 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), | |
| 260 | 'guid' => (string) $attachment->guid, | |
| 261 | 'mime_type' => (string) $attachment->post_mime_type, | |
| 262 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, | |
| 263 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, | |
| 264 | ); | |
| 265 | ||
| 266 | 		if ( isset( $metadata['duration'] ) ) { | |
| 267 | $result['duration'] = (int) $metadata['duration']; | |
| 268 | } | |
| 269 | ||
| 270 | return (object) apply_filters( 'get_attachment', $result ); | |
| 271 | } | |
| 272 | ||
| 273 | 	public function get_date() { | |
| 274 | return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date ); | |
| 275 | } | |