Ticket #20409: 20409.2.patch
| File 20409.2.patch, 5.0 KB (added by , 14 years ago) |
|---|
-
wp-includes/class-wp-xmlrpc-server.php
594 594 'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ), 595 595 ); 596 596 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_thumbnail_id( $post['ID'] ); 600 if ( $thumbnail_id ) { 601 $thumbnail_size = current_theme_supports('post-thumbnail') ? 'post-thumbnail' : 'thumbnail'; 602 $post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size ); 603 } 600 604 601 605 // Consider future posts as published 602 606 if ( $post_fields['post_status'] === 'future' ) … … 701 705 } 702 706 703 707 /** 708 * Prepares media item data for return in an XML-RPC object. 709 * 710 * @access protected 711 * 712 * @param object $media_item The unprepared media item data 713 * @param string $size The image size to use for the thumbnail URL 714 * @return array The prepared media item data 715 */ 716 protected function _prepare_media_item( $media_item, $thumbnail_size='thumbnail' ) { 717 $_media_item = array( 718 'attachment_id' => strval( $media_item->ID ), 719 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), 720 'parent' => $media_item->post_parent, 721 'link' => wp_get_attachment_url( $media_item->ID ), 722 'title' => $media_item->post_title, 723 'caption' => $media_item->post_excerpt, 724 'description' => $media_item->post_content, 725 'metadata' => wp_get_attachment_metadata( $media_item->ID ), 726 ); 727 728 $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); 729 if ( $thumbnail_src ) 730 $_media_item['thumbnail'] = $thumbnail_src[0]; 731 else 732 $_media_item['thumbnail'] = $_media_item['link']; 733 734 return apply_filters( 'xmlrpc__prepare_media_item', $_media_item, $media_item, $thumbnail_size ); 735 } 736 737 /** 704 738 * Create a new post for any registered post type. 705 739 * 706 740 * @uses wp_insert_post() … … 2820 2854 if ( ! $attachment = get_post($attachment_id) ) 2821 2855 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 2822 2856 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; 2857 return $this->_prepare_media_item( $attachment ); 2843 2858 } 2844 2859 2845 2860 /** … … 2866 2881 * @return array. Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents 2867 2882 */ 2868 2883 function wp_getMediaLibrary($args) { 2869 $raw_args = $args;2870 2884 $this->escape($args); 2871 2885 2872 2886 $blog_id = (int) $args[0]; … … 2888 2902 $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; 2889 2903 2890 2904 $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); 2891 $num_attachments = count($attachments);2892 2905 2893 if ( ! $num_attachments )2894 return array();2895 2896 2906 $attachments_struct = array(); 2897 2907 2898 2908 foreach ($attachments as $attachment ) 2899 $attachments_struct[] = $this-> wp_getMediaItem( array( $raw_args[0], $raw_args[1], $raw_args[2], $attachment->ID ));2909 $attachments_struct[] = $this->_prepare_media_item( $attachment ); 2900 2910 2901 2911 return $attachments_struct; 2902 2912 } … … 4210 4220 4211 4221 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; 4212 4222 4213 $resp['wp_post_thumbnail'] = get_post_meta( $postdata['ID'], '_thumbnail_id', true ); 4214 $resp['wp_post_thumbnail_url'] = wp_get_attachment_url( $resp['wp_post_thumbnail'] ); 4223 $resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] ); 4215 4224 4216 4225 return $resp; 4217 4226 } else { … … 4322 4331 ); 4323 4332 4324 4333 $entry_index = count( $struct ) - 1; 4325 $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_meta( $entry['ID'], '_thumbnail_id', true ); 4326 $struct[ $entry_index ][ 'wp_post_thumbnail_url' ] = wp_get_attachment_url( $struct[ $entry_index ][ 'wp_post_thumbnail' ] ); 4334 $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_thumbnail_id( $entry['ID'] ); 4327 4335 } 4328 4336 4329 4337 $recent_posts = array();