Ticket #6430: thumbnail_19Oct10.patch

File thumbnail_19Oct10.patch, 1.7 KB (added by jonquark, 3 years ago)

v3 of the patch

  • wp-includes/class.wp-xmlrpc-server.php

     
    27342734 
    27352735                // Save the data 
    27362736                $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 
    2737                 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 
     2737                $metadata = wp_generate_attachment_metadata( $id, $upload['file'] ); 
     2738                wp_update_attachment_metadata( $id, $metadata ); 
    27382739 
    2739                 return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ), 'upload' ); 
     2740                //setup the data to be returned 
     2741                $returneddata = array( 'file' => $name,  
     2742                                       'url' => $upload[ 'url' ], 
     2743                                       'type' => $type ); 
     2744 
     2745                //Get the URLs for each image we generated 
     2746                if(    isset($metadata['sizes']) 
     2747                    && is_array($metadata['sizes']) ) { 
     2748 
     2749                        //Find the filename as stored on disk (may 
     2750                        //not be the same as supplied by the client) 
     2751                        $savedfile = basename($metadata['file']); 
     2752 
     2753                        //for each size, copy the url for the fullsize image... 
     2754                        //...replacing the filename with the appropriate string 
     2755                        foreach( $metadata['sizes'] as $size => $size_data ) { 
     2756                                if( isset($size_data['file']) ) { 
     2757                                        $resized_url  =  str_replace(  $savedfile,  
     2758                                                                       $size_data['file'], 
     2759                                                                       $upload[ 'url' ]); 
     2760                                        $returneddata[ $size.'_url' ] = $resized_url; 
     2761                                } 
     2762                        } 
     2763                }       
     2764                return apply_filters( 'wp_handle_upload', $returneddata ); 
    27402765        } 
    27412766 
    27422767        /* MovableType API functions