Changeset 20608 for trunk/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 04/26/2012 08:56:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-xmlrpc-server.php
r20607 r20608 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 … … 699 703 700 704 return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); 705 } 706 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 ); 701 735 } 702 736 … … 2819 2853 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 2820 2854 2821 // Format page date. 2822 $attachment_date = $this->_convert_date( $attachment->post_date ); 2823 $attachment_date_gmt = $this->_convert_date_gmt( $attachment->post_date_gmt, $attachment->post_date ); 2824 2825 $link = wp_get_attachment_url($attachment->ID); 2826 $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); 2827 2828 $attachment_struct = array( 2829 'date_created_gmt' => $attachment_date_gmt, 2830 'parent' => $attachment->post_parent, 2831 'link' => $link, 2832 'thumbnail' => $thumbnail_link, 2833 'title' => $attachment->post_title, 2834 'caption' => $attachment->post_excerpt, 2835 'description' => $attachment->post_content, 2836 'metadata' => wp_get_attachment_metadata($attachment->ID), 2837 'attachment_id' => (string) $attachment->ID 2838 ); 2839 2840 return $attachment_struct; 2855 return $this->_prepare_media_item( $attachment ); 2841 2856 } 2842 2857 … … 2865 2880 */ 2866 2881 function wp_getMediaLibrary($args) { 2867 $raw_args = $args;2868 2882 $this->escape($args); 2869 2883 … … 2887 2901 2888 2902 $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); 2889 $num_attachments = count($attachments);2890 2891 if ( ! $num_attachments )2892 return array();2893 2903 2894 2904 $attachments_struct = array(); 2895 2905 2896 2906 foreach ($attachments as $attachment ) 2897 $attachments_struct[] = $this-> wp_getMediaItem( array( $raw_args[0], $raw_args[1], $raw_args[2], $attachment->ID ));2907 $attachments_struct[] = $this->_prepare_media_item( $attachment ); 2898 2908 2899 2909 return $attachments_struct; … … 4209 4219 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; 4210 4220 4211 $resp['wp_post_thumbnail'] = get_post_meta( $postdata['ID'], '_thumbnail_id', true ); 4212 $resp['wp_post_thumbnail_url'] = wp_get_attachment_url( $resp['wp_post_thumbnail'] ); 4221 $resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] ); 4213 4222 4214 4223 return $resp; … … 4321 4330 4322 4331 $entry_index = count( $struct ) - 1; 4323 $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_meta( $entry['ID'], '_thumbnail_id', true ); 4324 $struct[ $entry_index ][ 'wp_post_thumbnail_url' ] = wp_get_attachment_url( $struct[ $entry_index ][ 'wp_post_thumbnail' ] ); 4332 $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_thumbnail_id( $entry['ID'] ); 4325 4333 } 4326 4334
Note: See TracChangeset
for help on using the changeset viewer.