Media: Replace the thumbnail on post.php using a request variable instead of the referer. props ocean90. fixes #21391.

git-svn-id: http://core.svn.wordpress.org/trunk@22807 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-22 03:43:16 +00:00
parent 98494fdfe1
commit 0d08430cfe
3 changed files with 3 additions and 6 deletions

View File

@ -711,7 +711,7 @@ function wp_save_image( $post_id ) {
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
// Check if it's an image edit from attachment edit screen // 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 ); $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$return->thumbnail = $thumb_url[0]; $return->thumbnail = $thumb_url[0];
} else { } else {

View File

@ -2244,11 +2244,6 @@ function edit_form_image_editor() {
$title = esc_attr( $post->post_title ); $title = esc_attr( $post->post_title );
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); $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 = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
$media_dims = ''; $media_dims = '';
$meta = wp_get_attachment_metadata( $post->ID ); $meta = wp_get_attachment_metadata( $post->ID );
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 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 ) { foreach ( $extras['hidden'] as $hidden_field => $value ) {
echo '<input type="hidden" name="' . esc_attr( $hidden_field ) . '" value="' . esc_attr( $value ) . '" />' . "\n"; echo '<input type="hidden" name="' . esc_attr( $hidden_field ) . '" value="' . esc_attr( $value ) . '" />' . "\n";
} }
echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
} }
/** /**

View File

@ -245,6 +245,7 @@ imageEdit = {
'postid': postid, 'postid': postid,
'history': history, 'history': history,
'target': target, 'target': target,
'context': $('#image-edit-context').length ? $('#image-edit-context').val() : null,
'do': 'save' 'do': 'save'
}; };