Press This updates from noel. see #7732

git-svn-id: http://svn.automattic.com/wordpress/trunk@8959 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-09-22 22:04:10 +00:00
parent e5440f8156
commit f528acb8df
4 changed files with 44 additions and 19 deletions
+8 -2
View File
@@ -342,12 +342,18 @@ function media_upload_image() {
function media_sideload_image($file, $post_id, $desc = null) {
if (!empty($file) ) {
$file_array['name'] = basename($file);
$file_array['tmp_name'] = download_url($file);
$tmp = download_url($file);
$file_array['tmp_name'] = $tmp;
$desc = @$desc;
if ( is_wp_error($tmp) ) {
@unlink($file_array['tmp_name']);
$file_array['tmp_name'] = '';
}
$id = media_handle_sideload($file_array, $post_id, $desc);
$src = $id;
if ( is_wp_error($id) ) {
@unlink($file_array['tmp_name']);
return $id;