Properly refresh the thumbnail on post.php after an image edit. props ocean90. see #21391.

git-svn-id: http://core.svn.wordpress.org/trunk@22749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-11-21 12:05:24 +00:00
parent 9ad10730c0
commit 96576a2dca
2 changed files with 12 additions and 6 deletions

View File

@ -710,11 +710,17 @@ function wp_save_image( $post_id ) {
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
$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";
// Check if it's an image edit from attachment edit screen
if ( false !== strpos( wp_get_referer(), 'post.php' ) ) {
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$return->thumbnail = $thumb_url[0];
} else {
$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;

View File

@ -2269,7 +2269,7 @@ function edit_form_image_editor() {
<div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
<div class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>">
<p><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" width="<?php echo $thumb_url[1]; ?>" alt="" /></p>
<p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p>
<p><?php echo $image_edit_button; ?></p>
</div>
<div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>