Index: post.php
===================================================================
--- post.php	(revision 12419)
+++ post.php	(working copy)
@@ -1268,27 +1268,30 @@
  * @param int $postid Post ID.
  * @return mixed False on failure
  */
-function wp_trash_post($post_id = 0) {
-	if ( EMPTY_TRASH_DAYS == 0 )
-		return wp_delete_post($post_id);
+function wp_trash_post( $post_id = 0 ) {
+	if ( !EMPTY_TRASH_DAYS )
+		return wp_delete_post( $post_id );
 
-	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
+	if ( !$post = wp_get_single_post( $post_id, ARRAY_A ) )
 		return $post;
 
 	if ( $post['post_status'] == 'trash' )
 		return false;
 
+	if ( $post['post_type'] == 'attachment' && !MEDIA_TRASH )
+		return wp_delete_attachment( $post_id, true );
+
 	do_action('trash_post', $post_id);
 
-	add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
-	add_post_meta($post_id,'_wp_trash_meta_time', time());
+	add_post_meta( $post_id,'_wp_trash_meta_status', $post['post_status'] );
+	add_post_meta( $post_id,'_wp_trash_meta_time', time() );
 
 	$post['post_status'] = 'trash';
-	wp_insert_post($post);
+	wp_insert_post( $post );
 
-	wp_trash_post_comments($post_id);
+	wp_trash_post_comments( $post_id );
 
-	do_action('trashed_post', $post_id);
+	do_action( 'trashed_post', $post_id );
 
 	return $post;
 }
