Many thanks for help…
Download modified and replace files – https://maciej.kuzniczysko.pl/files/manual-image-crop.zip
Or modify it by your own:
wp-content\plugins\manual-image-crop\lib\ManualImageCrop.php
//prepares coordinates that will be passed to cropping function
$dst_x = 0;
$dst_y = 0;
$src_x = max(0, $_POST['select']['x']) * $_POST['previewScale'];
$src_y = max(0, $_POST['select']['y']) * $_POST['previewScale'];
$src_w = max(0, $_POST['select']['w']) * $_POST['previewScale'];
$src_h = max(0, $_POST['select']['h']) * $_POST['previewScale'];
//saves the selected area
$imageMetadata = wp_get_attachment_metadata($_POST['attachmentId']);
$imageMetadata['micSelectedArea'][$_POST['editedSize']] = array(
'x' => $_POST['select']['x'],
'y' => $_POST['select']['y'],
'w' => $_POST['select']['w'],
'h' => $_POST['select']['h'],
->
//prepares coordinates that will be passed to cropping function
$dst_x = 0;
$dst_y = 0;
$src_x = max(0, $_POST['select']['x']) * $_POST['previewScale'];
$src_y = max(0, $_POST['select']['y']) * $_POST['previewScale'];
$src_w = max(0, $_POST['select']['w']) * $_POST['previewScale'];
$src_h = max(0, $_POST['select']['h']) * $_POST['previewScale'];
$is_higher = ( $dst_h > wp_get_image_editor( $src_file )->get_size()["height"] );
$is_wider = ( $dst_w > wp_get_image_editor( $src_file )->get_size()["width"] );
if ( $is_higher || $is_wider ) :
if ( $is_higher )
$scale = $src_h / wp_get_image_editor( $src_file )->get_size()["height"];
else
$scale = $src_w / wp_get_image_editor( $src_file )->get_size()["width"];
$src_w = $src_w / $scale;
$src_h = $src_h / $scale;
$src_x = $src_x / $scale;
$src_y = $src_y / $scale;
endif;
//saves the selected area
$imageMetadata = wp_get_attachment_metadata($_POST['attachmentId']);
$imageMetadata['micSelectedArea'][$_POST['editedSize']] = array(
'x' => $_POST['select']['x'],
'y' => $_POST['select']['y'],
'w' => $_POST['select']['w'],
'h' => $_POST['select']['h'],
wp-content\plugins\manual-image-crop\lib\ManualImageCropEditorWindow.php
$src_file_url = wp_get_attachment_image_src($_GET['postId'], 'full');
if (!$src_file_url) {
echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
exit;
}
$src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
$sizes = getimagesize($src_file);
$previewWidth = min($sizes[0], 500);
$previewHeight = min($sizes[1], 350);
$previewRatio = 1;
->
$src_file_url = wp_get_attachment_image_src($_GET['postId'], 'full');
if (!$src_file_url) {
echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
exit;
}
$src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
$sizes = getimagesize($src_file);
$original[0] = $sizes[0];
$original[1] = $sizes[1];
if ($width > $sizes[0]) {
$sizes[1] = ( $sizes[1] * ($width / $sizes[0]) );
$height = ceil($height);
$sizes[0] = $width;
}
$previewWidth = min($sizes[0], 500);
$previewHeight = min($sizes[1], 350);
$previewRatio = 1;
and
<?php _e('Original picture dimensions:','microp') ?> <strong><?php echo $sizes[0]; ?> x <?php echo $sizes[1]; ?> px</strong><br />
->
<?php _e('Original picture dimensions:','microp') ?> <strong><?php echo $original[0]; ?> x <?php echo $original[1]; ?> px</strong><br />