Index: press-this.php
===================================================================
--- press-this.php	(revision 8166)
+++ press-this.php	(working copy)
@@ -30,7 +30,7 @@
 				# 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 @@
 	$quick['post_content'] = str_replace('<br />', "\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 @@
 	?>
 	</head>
 	<body class="press-this">
+		
 		<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&amp;post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();">Close Window</a></p></div>
 		
 		<div id="footer">
@@ -182,7 +185,7 @@
 
 if($_REQUEST['ajax'] == 'photo_js') { ?>
 
-			tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox
+			//tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox
 			
 			function image_selector() {
 				desc = jQuery('#this_photo_description').val();
@@ -228,7 +231,7 @@
 				cache : false,
 				async : false,
 			   	data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
-				dataType : "script"
+				dataType : "script",
 				}).responseText);
 
 			for (i = 0; i < my_src.length; i++) {
@@ -251,9 +254,9 @@
 				}
 
 				if (!skip) strtoappend += '<a href="?ajax=thickbox&amp;i=' + img.src + '&amp;u=<?php echo $url; ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
-
 			}
 			jQuery('#img_container').html(strtoappend);
+			tb_init('a.thickbox, area.thickbox, input.thickbox');
 
 <?php die; }
 
