| 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 ); |