From 4e20ae5719a03d223847551ca9e4ae27175b51d8 Mon Sep 17 00:00:00 2001
From: azaozz <azaozz@1a063a9b-81f0-0310-95a4-ce76da25c4cd>
Date: Wed, 30 Sep 2009 23:39:09 +0000
Subject: [PATCH] Image Editor: fix refreshing of the thumbnail, use
 WP_Http_Fopen::test(), see #10528

git-svn-id: http://svn.automattic.com/wordpress/trunk@11985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
 wp-admin/includes/image-edit.php | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
index dcc0a6cc9d..936f093fae 100644
--- a/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -218,7 +218,7 @@ function load_image_to_edit($post_id, $mime_type, $size = 'full') {
 	if ( $filepath && file_exists($filepath) ) {
 		if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) )
 			$filepath = path_join( dirname($filepath), $data['file'] );
-	} elseif ( function_exists('fopen') ) {
+	} elseif ( WP_Http_Fopen::test() ) {
 		$filepath = wp_get_attachment_url($post_id);
 	}
 
@@ -627,10 +627,11 @@ function wp_save_image($post_id) {
 		update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
 
 		if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
-			if ( $thumb = $meta['sizes']['thumbnail'] ) {
-				$file_url = wp_get_attachment_url($post_id);
+			$file_url = wp_get_attachment_url($post_id);
+			if ( $thumb = $meta['sizes']['thumbnail'] )
 				$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
-			}
+			else
+				$return->thumbnail = "$file_url?w=128&h=128";
 		}
 	} else {
 		$delete = true;