Manual Image Crop - Version 1.03

Version Description

  • Fixed the issue with overwriting the original image when cropping image size registered after the attachment had been uploaded
Download this release

Release Info

Developer tomasz.sita
Plugin Icon 128x128 Manual Image Crop
Version 1.03
Comparing to
See all releases

Code changes from version 1.02 to 1.03

Files changed (3) hide show
  1. lib/ManualImageCrop.php +13 -0
  2. manual-image-crop.php +1 -1
  3. readme.txt +12 -9
lib/ManualImageCrop.php CHANGED
@@ -149,6 +149,19 @@ setInterval(function() {
149
  }
150
  $dst_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $dst_file_url[0]);
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  if (isset($_wp_additional_image_sizes[$_POST['editedSize']])) {
153
  $dst_w = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['width']), $_POST['select']['w'] * $_POST['previewScale']);;
154
  $dst_h = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['height']), $_POST['select']['h'] * $_POST['previewScale']);
149
  }
150
  $dst_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $dst_file_url[0]);
151
 
152
+ if ($dst_file == $src_file) {
153
+ $attachmentData = wp_generate_attachment_metadata( $_POST['attachmentId'], $dst_file );
154
+
155
+ //new destination file path - replaces original file name with the correct one
156
+ $dst_file = str_replace( basename($attachmentData['file']), $attachmentData['sizes'][ $_POST['editedSize'] ]['file'], $dst_file);
157
+
158
+ //saves new path to the image size in the database
159
+ wp_update_attachment_metadata( $_POST['attachmentId'], $attachmentData );
160
+
161
+ //retirives the new url to file (needet to refresh the preview)
162
+ $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
163
+ }
164
+
165
  if (isset($_wp_additional_image_sizes[$_POST['editedSize']])) {
166
  $dst_w = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['width']), $_POST['select']['w'] * $_POST['previewScale']);;
167
  $dst_h = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['height']), $_POST['select']['h'] * $_POST['previewScale']);
manual-image-crop.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Manual Image Crop
4
  Plugin URI: http://www.rocketmill.co.uk/wordpress-plugin-manual-image-crop
5
  Description: Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image). Simply click on the "Crop" link next to any image in your media library and select the area of the image you want to crop.
6
- Version: 1.02
7
  Author: Tomasz Sita
8
  Author URI: http://www.rocketmill.co.uk/author/tomasz
9
  License: GPL2
3
  Plugin Name: Manual Image Crop
4
  Plugin URI: http://www.rocketmill.co.uk/wordpress-plugin-manual-image-crop
5
  Description: Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image). Simply click on the "Crop" link next to any image in your media library and select the area of the image you want to crop.
6
+ Version: 1.03
7
  Author: Tomasz Sita
8
  Author URI: http://www.rocketmill.co.uk/author/tomasz
9
  License: GPL2
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: tomasz.sita
3
  Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
4
  Requires at least: 3.0.1
5
- Tested up to: 3.6
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
- Stable tag: 1.02
9
 
10
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
11
 
@@ -18,8 +18,8 @@ The "lightbox" style interface will be brought up and you are ready to go.
18
  Whole cropping process is really intuitive and simple.
19
 
20
  Apart from media library list, the plugin adds links in few more places:
21
- -below featured image box ("Crop featured image")
22
- -In the media insert modal window (once you select an image)
23
 
24
 
25
  == Installation ==
@@ -35,13 +35,16 @@ Automatically:
35
 
36
  == Changelog ==
37
 
 
 
 
38
  = 1.02 =
39
- -Fixed HTTP Authentication no preview issue
40
- -Fixed path issues on multisite/subfolder WP installations
41
 
42
  = 1.01 =
43
- -Fixed Chrome stretched image issue
44
- -Improved compatibility with other plugins using 'thickbox'
45
 
46
  = 1.0 =
47
- Initial version
2
  Contributors: tomasz.sita
3
  Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
4
  Requires at least: 3.0.1
5
+ Tested up to: 3.7
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ Stable tag: 1.03
9
 
10
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
11
 
18
  Whole cropping process is really intuitive and simple.
19
 
20
  Apart from media library list, the plugin adds links in few more places:
21
+ * Below featured image box ("Crop featured image")
22
+ * In the media insert modal window (once you select an image)
23
 
24
 
25
  == Installation ==
35
 
36
  == Changelog ==
37
 
38
+ = 1.03 =
39
+ * Fixed the issue with overwriting the original image when cropping image size registered after the attachment had been uploaded
40
+
41
  = 1.02 =
42
+ * Fixed HTTP Authentication no preview issue
43
+ * Fixed path issues on multisite/subfolder WP installations
44
 
45
  = 1.01 =
46
+ * Fixed Chrome stretched image issue
47
+ * Improved compatibility with other plugins using 'thickbox'
48
 
49
  = 1.0 =
50
+ * Initial version