diff --git a/wp-admin/css/press-this.css b/wp-admin/css/press-this.css index 64920abaed..71a41259d4 100644 --- a/wp-admin/css/press-this.css +++ b/wp-admin/css/press-this.css @@ -294,26 +294,38 @@ div#categories h2 { height: 100px; } +#img_container a { + display: block; + width: 79px; + height: 79px; + float: left; +} #img_container img { width: 75px; height: 75px; + border: 0px; padding: 2px; background-color: #f4f4f4; - margin-right: 7px; - margin-bottom: 7px; cursor: pointer; } +#img_container a, #img_container a:link, #img_container a:visited { + border: 2px solid #ccc; + margin: 0 4px 4px 0; +} +#img_container a:hover, #img_container a:active { + border: 2px solid #000; +} .submit { --moz-border-radius-bottomleft: 3px; --khtml-border-bottom-left-radius: 3px; --webkit-border-bottom-left-radius: 3px; -border-bottom-left-radius: 3px; --moz-border-radius-bottomright: 3px; --khtml-border-bottom-right-radius: 3px; --webkit-border-bottom-right-radius: 3px; -border-bottom-right-radius: 3px; -margin: 0; -padding: 0; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -moz-border-radius-bottomright: 3px; + -khtml-border-bottom-right-radius: 3px; + -webkit-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; + margin: 0; + padding: 0; } .submitbox { width: 100%; @@ -466,9 +478,9 @@ margin-bottom: 8px; } #post_status { -margin-left: 10px; -margin-bottom: 1em; -display: block; + margin-left: 10px; + margin-bottom: 1em; + display: block; } #footer { diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 4d42def8d7..8d9029f72e 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 = "$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,9 +151,10 @@ 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 $src; } - - return array('id' => $id, 'src' => $url); + + return $id; } @@ -348,6 +314,33 @@ 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); + unset($file_array); + + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + return $id; + } else { + $src = $id; + } + } + + if (!empty($src) && !strpos($src, '://') ) { + $src = "http://$src"; + $alt = @$desc; + } + if ( !empty($src) ) { + $html = "$alt"; + return $html; + } +} + function media_upload_audio() { if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index ce990ecec8..b07a0a3e69 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -30,7 +30,7 @@ function press_it() { # see if files exist in content - we don't want to upload non-used selected files. preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]); if($matches[0]) - media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]); + $upload = media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]); } $content = $_REQUEST['content']; break; @@ -45,11 +45,13 @@ function press_it() { $quick['post_content'] = str_replace('
', "\n", preg_replace('/<\/?p>/','',$content)); #error handling for $post - if ( is_wp_error($post_ID) ) { + if ( is_wp_error($post_ID)) { wp_die($id); wp_delete_post($post_ID); - #error handling for media_sideload + } elseif ( is_wp_error($upload)) { + wp_die($upload); + wp_delete_post($post_ID); } else { $quick['ID'] = $post_ID; wp_update_post($quick); @@ -78,6 +80,7 @@ if ( 'post' == $_REQUEST['action'] ) { ?> +

| | Close Window