--- a/wp/wp-admin/includes/image-edit.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-admin/includes/image-edit.php Fri Sep 05 18:52:52 2025 +0200
@@ -75,9 +75,9 @@
) ) {
$note_no_rotate = '';
?>
- <button type="button" class="imgedit-rleft button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° left' ); ?></button>
- <button type="button" class="imgedit-rright button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° right' ); ?></button>
- <button type="button" class="imgedit-rfull button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 180°' ); ?></button>
+ <button type="button" class="imgedit-rleft button" onkeydown="imageEdit.browsePopup(event, this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° left' ); ?></button>
+ <button type="button" class="imgedit-rright button" onkeydown="imageEdit.browsePopup(event, this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° right' ); ?></button>
+ <button type="button" class="imgedit-rfull button" onkeydown="imageEdit.browsePopup(event, this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 180°' ); ?></button>
<?php
} else {
$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
@@ -88,8 +88,8 @@
}
?>
<hr />
- <button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
- <button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
+ <button type="button" onkeydown="imageEdit.browsePopup(event, this)" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
+ <button type="button" onkeydown="imageEdit.browsePopup(event, this)" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
<?php echo $note_no_rotate; ?>
</div>
</div>
@@ -293,7 +293,7 @@
</div>
<div class="imgedit-thumbnail-preview-group">
<figure class="imgedit-thumbnail-preview">
- <img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
+ <img src="<?php echo esc_url( $thumb['url'] ); ?>" width="<?php echo esc_attr( $thumb_img[0] ); ?>" height="<?php echo esc_attr( $thumb_img[1] ); ?>" class="imgedit-size-preview" alt="" draggable="false" />
<figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
</figure>
<div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target">
@@ -534,8 +534,8 @@
* @see WP_Image_Editor::rotate()
*
* @ignore
- * @param resource|GdImage $img Image resource.
- * @param float|int $angle Image rotation angle, in degrees.
+ * @param resource|GdImage $img Image resource.
+ * @param float|int $angle Image rotation angle, in degrees.
* @return resource|GdImage|false GD image resource or GdImage instance, false otherwise.
*/
function _rotate_image_resource( $img, $angle ) {
@@ -735,10 +735,10 @@
$w = $size['width'];
$h = $size['height'];
- $scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
+ $scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
$image->crop( (int) ( $sel->x * $scale ), (int) ( $sel->y * $scale ), (int) ( $sel->w * $scale ), (int) ( $sel->h * $scale ) );
} else {
- $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
+ $scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
}
break;
@@ -826,9 +826,10 @@
}
} elseif ( isset( $meta['width'], $meta['height'] ) ) {
$backup_sizes[ "full-$suffix" ] = array(
- 'width' => $meta['width'],
- 'height' => $meta['height'],
- 'file' => $parts['basename'],
+ 'width' => $meta['width'],
+ 'height' => $meta['height'],
+ 'filesize' => $meta['filesize'],
+ 'file' => $parts['basename'],
);
}
}
@@ -839,6 +840,14 @@
$meta['file'] = _wp_relative_upload_path( $restored_file );
$meta['width'] = $data['width'];
$meta['height'] = $data['height'];
+ if ( isset( $data['filesize'] ) ) {
+ /*
+ * Restore the original filesize if it was backed up.
+ *
+ * See https://core.trac.wordpress.org/ticket/59684.
+ */
+ $meta['filesize'] = $data['filesize'];
+ }
}
foreach ( $default_sizes as $default_size ) {
@@ -997,8 +1006,9 @@
}
}
+ $saved_image = wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id );
// Save the full-size file, also needed to create sub-sizes.
- if ( ! wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ) ) {
+ if ( ! $saved_image ) {
$return->error = esc_js( __( 'Unable to save the image.' ) );
return $return;
}
@@ -1018,9 +1028,10 @@
if ( $tag ) {
$backup_sizes[ $tag ] = array(
- 'width' => $meta['width'],
- 'height' => $meta['height'],
- 'file' => $basename,
+ 'width' => $meta['width'],
+ 'height' => $meta['height'],
+ 'filesize' => $meta['filesize'],
+ 'file' => $basename,
);
}
@@ -1028,9 +1039,10 @@
$meta['file'] = _wp_relative_upload_path( $new_path );
- $size = $img->get_size();
- $meta['width'] = $size['width'];
- $meta['height'] = $size['height'];
+ $size = $img->get_size();
+ $meta['width'] = $size['width'];
+ $meta['height'] = $size['height'];
+ $meta['filesize'] = $saved_image['filesize'];
if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) {
$sizes = get_intermediate_image_sizes();