diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
index 0ac9ca5533..b0e95ed124 100644
--- a/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -711,7 +711,7 @@ function wp_save_image( $post_id ) {
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
// Check if it's an image edit from attachment edit screen
- if ( false !== strpos( wp_get_referer(), 'post.php' ) ) {
+ if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$return->thumbnail = $thumb_url[0];
} else {
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 65034fa7a4..343c9fd5c8 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -2244,11 +2244,6 @@ function edit_form_image_editor() {
$title = esc_attr( $post->post_title );
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
- $post_mime_types = get_post_mime_types();
- $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
- $type = array_shift( $keys );
- $type_html = "";
-
$media_dims = '';
$meta = wp_get_attachment_metadata( $post->ID );
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
@@ -2294,6 +2289,7 @@ function edit_form_image_editor() {
foreach ( $extras['hidden'] as $hidden_field => $value ) {
echo '' . "\n";
}
+ echo '' . "\n";
}
/**
diff --git a/wp-admin/js/image-edit.js b/wp-admin/js/image-edit.js
index bc5a49c059..b11e2d3ab0 100644
--- a/wp-admin/js/image-edit.js
+++ b/wp-admin/js/image-edit.js
@@ -245,6 +245,7 @@ imageEdit = {
'postid': postid,
'history': history,
'target': target,
+ 'context': $('#image-edit-context').length ? $('#image-edit-context').val() : null,
'do': 'save'
};