@@ 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 |
@@ 276-294 (lines=19) @@ | ||
273 | return $format; |
|
274 | } |
|
275 | ||
276 | private function get_attachment( $attachment ) { |
|
277 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
278 | ||
279 | $result = array( |
|
280 | 'ID' => (int) $attachment->ID, |
|
281 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
282 | 'guid' => (string) $attachment->guid, |
|
283 | 'mime_type' => (string) $attachment->post_mime_type, |
|
284 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
285 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
286 | ); |
|
287 | ||
288 | if ( isset( $metadata['duration'] ) ) { |
|
289 | $result['duration'] = (int) $metadata['duration']; |
|
290 | } |
|
291 | ||
292 | /** This filter is documented in class.jetpack-sync.php */ |
|
293 | return (object) apply_filters( 'get_attachment', $result ); |
|
294 | } |
|
295 | ||
296 | public function get_date() { |
|
297 | return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date ); |