diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-06-24 17:00:10 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-06-24 17:00:10 +0000 |
commit | 631c9bb4d60d242432052f56c00768392f42a392 (patch) | |
tree | 50d41b0248d5c5fb156c6d52020675208b77a3e6 /wp-admin/includes/media.php | |
parent | a1fbe4e0694a66d7351e2f6280ab84568681e8e0 (diff) | |
download | wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.gz wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.xz wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.zip |
WP Merge to revision 8180
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1336 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/includes/media.php')
-rw-r--r-- | wp-admin/includes/media.php | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 4d42def..d6fdec2 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -115,41 +115,6 @@ function media_handle_upload($file_id, $post_id, $post_data = array()) { } - -function media_sideload_image($file, $post_id, $desc = null) { - - if (!empty($file) ) { - // Upload File button was clicked - - $file_array['name'] = basename($file); - $file_array['tmp_name'] = download_url($file); - $desc = @$desc; - - $sideload = media_handle_sideload($file_array, $post_id, $desc); - - $id = $sideload['id']; - $src = $sideload['src']; - - unset($file_array['tmp_name']); - unset($file_array); - - if ( is_wp_error($id) ) { - $errors['upload_error'] = $id; - $id = false; - } - } - - if ( !empty($src) && !strpos($src, '://') ) - - $src = "http://$src"; - $alt = @$desc; - - if ( !empty($src) ) - $html = "<img src='$src' alt='$alt' />"; - return $html; - -} - function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { $overrides = array('test_form'=>false); $file = wp_handle_sideload($file_array, $overrides); @@ -186,10 +151,9 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = $id = wp_insert_attachment($attachment, $file, $post_parent); if ( !is_wp_error($id) ) { wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + return $url; } - - return array('id' => $id, 'src' => $url); - + return $id; } @@ -348,6 +312,32 @@ function media_upload_image() { return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); } +function media_sideload_image($file, $post_id, $desc = null) { + if (!empty($file) ) { + $file_array['name'] = basename($file); + $file_array['tmp_name'] = download_url($file); + $desc = @$desc; + + $id = media_handle_sideload($file_array, $post_id, $desc); + $src = $id; + + unset($file_array); + + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + return $id; + } + } + + if ( !empty($src) ) { + if ( !strpos($src, '://') ) + $src = "http://$src"; + $alt = @$desc; + $html = "<img src='$src' alt='$alt' />"; + return $html; + } +} + function media_upload_audio() { if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked |