| @@ 287-305 (lines=19) @@ | ||
| 284 | return $format; |
|
| 285 | } |
|
| 286 | ||
| 287 | private function get_attachment( $attachment ) { |
|
| 288 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
| 289 | ||
| 290 | $result = array( |
|
| 291 | 'ID' => (int) $attachment->ID, |
|
| 292 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
| 293 | 'guid' => (string) $attachment->guid, |
|
| 294 | 'mime_type' => (string) $attachment->post_mime_type, |
|
| 295 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
| 296 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
| 297 | ); |
|
| 298 | ||
| 299 | if ( isset( $metadata['duration'] ) ) { |
|
| 300 | $result['duration'] = (int) $metadata['duration']; |
|
| 301 | } |
|
| 302 | ||
| 303 | /** This filter is documented in class.jetpack-sync.php */ |
|
| 304 | return (object) apply_filters( 'get_attachment', $result ); |
|
| 305 | } |
|
| 306 | ||
| 307 | public function get_date() { |
|
| 308 | return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date ); |
|
| @@ 590-608 (lines=19) @@ | ||
| 587 | * |
|
| 588 | * @return object |
|
| 589 | */ |
|
| 590 | function get_attachment( $attachment ) { |
|
| 591 | $metadata = wp_get_attachment_metadata( $attachment->ID ); |
|
| 592 | ||
| 593 | $result = array( |
|
| 594 | 'ID' => (int) $attachment->ID, |
|
| 595 | 'URL' => (string) wp_get_attachment_url( $attachment->ID ), |
|
| 596 | 'guid' => (string) $attachment->guid, |
|
| 597 | 'mime_type' => (string) $attachment->post_mime_type, |
|
| 598 | 'width' => (int) isset( $metadata['width'] ) ? $metadata['width'] : 0, |
|
| 599 | 'height' => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0, |
|
| 600 | ); |
|
| 601 | ||
| 602 | if ( isset( $metadata['duration'] ) ) { |
|
| 603 | $result['duration'] = (int) $metadata['duration']; |
|
| 604 | } |
|
| 605 | ||
| 606 | return (object) apply_filters( 'get_attachment', $result ); |
|
| 607 | } |
|
| 608 | ||
| 609 | /** |
|
| 610 | * Get post-specific user capabilities |
|
| 611 | * @param WP_Post $post post object |
|