X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/00dbffaf1593b0ac719d98f00839221a9ca52133..ceb5a929e00123b4e224977c6b5a149f6431b250:/wp-admin/includes/image-edit.php diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index 01bce7bd..f25546e5 100644 --- a/wp-admin/includes/image-edit.php +++ b/wp-admin/includes/image-edit.php @@ -13,7 +13,7 @@ function wp_image_editor($post_id, $msg = false) { $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); $note = ''; - if ( is_array($meta) && isset($meta['width']) ) + if ( isset( $meta['width'], $meta['height'] ) ) $big = max( $meta['width'], $meta['height'] ); else die( __('Image data does not exist. Please re-upload the image.') ); @@ -21,8 +21,9 @@ function wp_image_editor($post_id, $msg = false) { $sizer = $big > 400 ? 400 / $big : 1; $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); - $can_restore = !empty($backup_sizes) && isset($backup_sizes['full-orig']) - && $backup_sizes['full-orig']['file'] != basename($meta['file']); + $can_restore = false; + if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) + $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); if ( $msg ) { if ( isset($msg->error) ) @@ -63,8 +64,8 @@ function wp_image_editor($post_id, $msg = false) { - - + +
@@ -81,10 +82,12 @@ function wp_image_editor($post_id, $msg = false) {
-

+

+

+
- × + × ! , 'scale')" class="button-primary" value="" />
@@ -256,6 +259,7 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { switch ( $mime_type ) { case 'image/jpeg': + /** This filter is documented in wp-includes/class-wp-image-editor.php */ return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); case 'image/png': return imagepng( $image, $filename ); @@ -454,7 +458,7 @@ function stream_preview_image( $post_id ) { if ( is_wp_error( $img ) ) return false; - $changes = !empty($_REQUEST['history']) ? json_decode( stripslashes($_REQUEST['history']) ) : null; + $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; if ( $changes ) $img = image_edit_apply_changes( $img, $changes ); @@ -464,8 +468,8 @@ function stream_preview_image( $post_id ) { $h = $size['height']; $ratio = _image_get_preview_ratio( $w, $h ); - $w2 = $w * $ratio; - $h2 = $h * $ratio; + $w2 = max ( 1, $w * $ratio ); + $h2 = max ( 1, $h * $ratio ); if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) return false; @@ -496,10 +500,11 @@ function wp_restore_image($post_id) { if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { // delete only if it's edited image if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { + /** This filter is documented in wp-admin/custom-header.php */ $delpath = apply_filters('wp_delete_file', $file); @unlink($delpath); } - } else { + } elseif ( isset( $meta['width'], $meta['height'] ) ) { $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); } } @@ -519,6 +524,7 @@ function wp_restore_image($post_id) { if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { // delete only if it's edited image if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) { + /** This filter is documented in wp-admin/custom-header.php */ $delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) ); @unlink($delpath); } @@ -587,7 +593,7 @@ function wp_save_image( $post_id ) { return $return; } } elseif ( !empty($_REQUEST['history']) ) { - $changes = json_decode( stripslashes($_REQUEST['history']) ); + $changes = json_decode( wp_unslash($_REQUEST['history']) ); if ( $changes ) $img = image_edit_apply_changes($img, $changes); } else { @@ -719,6 +725,7 @@ function wp_save_image( $post_id ) { } if ( $delete ) { + /** This filter is documented in wp-admin/custom-header.php */ $delpath = apply_filters('wp_delete_file', $new_path); @unlink( $delpath ); }