| @@ 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 ); |
|
| @@ 593-611 (lines=19) @@ | ||
| 590 | * |
|
| 591 | * @return object |
|
| 592 | */ |
|
| 593 | function get_attachment( $attachment ) { |
|
| 594 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
| 595 | ||
| 596 | $result = array( |
|
| 597 | 'ID' => (int) $attachment->ID, |
|
| 598 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
| 599 | 'guid' => (string) $attachment->guid, |
|
| 600 | 'mime_type' => (string) $attachment->post_mime_type, |
|
| 601 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
| 602 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
| 603 | ); |
|
| 604 | ||
| 605 | if ( isset( $metadata['duration'] ) ) { |
|
| 606 | $result['duration'] = (int) $metadata['duration']; |
|
| 607 | } |
|
| 608 | ||
| 609 | return (object) apply_filters( 'get_attachment', $result ); |
|
| 610 | } |
|
| 611 | ||
| 612 | /** |
|
| 613 | * Get post-specific user capabilities |
|
| 614 | * @param WP_Post $post post object |
|