@@ 622-640 (lines=19) @@ | ||
619 | * |
|
620 | * @return (object) |
|
621 | */ |
|
622 | function get_attachment( $attachment ) { |
|
623 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
624 | ||
625 | $result = array( |
|
626 | 'ID' => (int) $attachment->ID, |
|
627 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
628 | 'guid' => (string) $attachment->guid, |
|
629 | 'mime_type' => (string) $attachment->post_mime_type, |
|
630 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
631 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
632 | ); |
|
633 | ||
634 | if ( isset( $metadata['duration'] ) ) { |
|
635 | $result['duration'] = (int) $metadata['duration']; |
|
636 | } |
|
637 | ||
638 | return (object) apply_filters( 'get_attachment', $result ); |
|
639 | } |
|
640 | ||
641 | /** |
|
642 | * Get post-specific user capabilities |
|
643 | * @param WP_Post $post post object |
@@ 281-299 (lines=19) @@ | ||
278 | return $format; |
|
279 | } |
|
280 | ||
281 | private function get_attachment( $attachment ) { |
|
282 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
283 | ||
284 | $result = array( |
|
285 | 'ID' => (int) $attachment->ID, |
|
286 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
287 | 'guid' => (string) $attachment->guid, |
|
288 | 'mime_type' => (string) $attachment->post_mime_type, |
|
289 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
290 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
291 | ); |
|
292 | ||
293 | if ( isset( $metadata['duration'] ) ) { |
|
294 | $result['duration'] = (int) $metadata['duration']; |
|
295 | } |
|
296 | ||
297 | /** This filter is documented in class.jetpack-sync.php */ |
|
298 | return (object) apply_filters( 'get_attachment', $result ); |
|
299 | } |
|
300 | ||
301 | public function get_date() { |
|
302 | return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date ); |