| 597 | | // |
| 598 | | $post_fields['post_thumbnail'] = get_post_meta( $post['ID'], '_thumbnail_id', true ); |
| 599 | | $post_fields['post_thumbnail_url'] = wp_get_attachment_url( $post_fields['post_thumbnail'] ); |
| | 597 | // Thumbnail |
| | 598 | $post_fields['post_thumbnail'] = array(); |
| | 599 | $thumbnail_id = get_post_meta( $post['ID'], '_thumbnail_id', true ); |
| | 600 | if ( $thumbnail_id ) { |
| | 601 | $thumbnail_size = 'thumbnail'; |
| | 602 | if ( current_theme_supports('post-thumbnail') ) |
| | 603 | $thumbnail_size = 'post-thumbnail'; |
| | 604 | $post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size ); |
| | 605 | } |
| | 710 | * Prepares media item data for return in an XML-RPC object. |
| | 711 | * |
| | 712 | * @access protected |
| | 713 | * |
| | 714 | * @param object $media_item The unprepared media item data |
| | 715 | * @param string $size The image size to use for the thumbnail URL |
| | 716 | * @return array The prepared media item data |
| | 717 | */ |
| | 718 | protected function _prepare_media_item( $media_item, $thumbnail_size='thumbnail' ) { |
| | 719 | $_media_item = array( |
| | 720 | 'attachment_id' => strval( $media_item->ID ), |
| | 721 | 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), |
| | 722 | 'parent' => $media_item->post_parent, |
| | 723 | 'link' => wp_get_attachment_url( $media_item->ID ), |
| | 724 | 'title' => $media_item->post_title, |
| | 725 | 'caption' => $media_item->post_excerpt, |
| | 726 | 'description' => $media_item->post_content, |
| | 727 | 'metadata' => wp_get_attachment_metadata( $media_item->ID ), |
| | 728 | ); |
| | 729 | |
| | 730 | $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); |
| | 731 | if ( $thumbnail_src ) |
| | 732 | $_media_item['thumbnail'] = $thumbnail_src[0]; |
| | 733 | else |
| | 734 | $_media_item['thumbnail'] = $_media_item['link']; |
| | 735 | |
| | 736 | return apply_filters( 'xmlrpc__prepare_media_item', $_media_item, $media_item, $thumbnail_size ); |
| | 737 | } |
| | 738 | |
| | 739 | /** |
| 2823 | | // Format page date. |
| 2824 | | $attachment_date = $this->_convert_date( $attachment->post_date ); |
| 2825 | | $attachment_date_gmt = $this->_convert_date_gmt( $attachment->post_date_gmt, $attachment->post_date ); |
| 2826 | | |
| 2827 | | $link = wp_get_attachment_url($attachment->ID); |
| 2828 | | $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); |
| 2829 | | |
| 2830 | | $attachment_struct = array( |
| 2831 | | 'date_created_gmt' => $attachment_date_gmt, |
| 2832 | | 'parent' => $attachment->post_parent, |
| 2833 | | 'link' => $link, |
| 2834 | | 'thumbnail' => $thumbnail_link, |
| 2835 | | 'title' => $attachment->post_title, |
| 2836 | | 'caption' => $attachment->post_excerpt, |
| 2837 | | 'description' => $attachment->post_content, |
| 2838 | | 'metadata' => wp_get_attachment_metadata($attachment->ID), |
| 2839 | | 'attachment_id' => (string) $attachment->ID |
| 2840 | | ); |
| 2841 | | |
| 2842 | | return $attachment_struct; |
| | 2859 | return $this->_prepare_media_item( $attachment ); |