Manual Image Crop - Version 1.04

Version Description

  • Added remembering of the previously selected area after cropping the specific image size
  • Fixed the "wp_enqueue_script was called incorrectly" warning in the WP debug mode
Download this release

Release Info

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

Code changes from version 1.03 to 1.04

lib/ManualImageCrop.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  class ManualImageCrop {
3
 
4
  private static $instance;
@@ -22,6 +27,8 @@ class ManualImageCrop {
22
  * Enqueues all necessary CSS and Scripts
23
  */
24
  public function enqueueAssets() {
 
 
25
  wp_register_style( 'rct-admin', plugins_url('assets/css/mic-admin.css', dirname( __FILE__ ) ) );
26
  wp_enqueue_style( 'rct-admin' );
27
 
@@ -37,7 +44,6 @@ class ManualImageCrop {
37
  * Hooks Editor Links into proper places
38
  */
39
  public function addEditorLinks() {
40
- add_thickbox();
41
  add_action( 'media_row_actions', array($this, 'addMediaEditorLinks'), 10, 2 );
42
  add_action( 'admin_post_thumbnail_html', array($this, 'addCropFeatureImageEditorLink'), 10, 2 );
43
  add_action( 'print_media_templates', array($this, 'addAttachementEditLink') );
@@ -49,7 +55,7 @@ class ManualImageCrop {
49
  */
50
  public function addMediaEditorLinks($links, $post) {
51
  if (preg_match('/image/', $post->post_mime_type)) {
52
- $links['crop'] = '<a class="thickbox mic-link" rel="crop" title="Crop" href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&postId=' . $post->ID . '">Crop</a>';
53
  }
54
  return $links;
55
  }
@@ -58,7 +64,7 @@ class ManualImageCrop {
58
  * Adds link below "Remoce feature image" in post editing form
59
  */
60
  public function addCropFeatureImageEditorLink($content, $post) {
61
- $content .= '<a id="micCropFeatureImage" class="thickbox mic-link" rel="crop" title="Crop" href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&postId=' . get_post_thumbnail_id($post) . '">Crop featured image</a>
62
  <script>
63
  setInterval(function() {
64
  if (jQuery(\'#remove-post-thumbnail\').is(\':visible\')) {
@@ -72,11 +78,9 @@ setInterval(function() {
72
  }
73
 
74
  /**
75
- * Ads link in the ligthbox media library
76
  */
77
-
78
- public function addAttachementEditLink() {
79
- ?>
80
  <script>
81
  var micEditAttachemtnLinkAdded = false;
82
  var micEditAttachemtnLinkAddedInterval = 0;
@@ -87,7 +91,7 @@ setInterval(function() {
87
  var mRegexp = /\?post=([0-9]+)/;
88
  var match = mRegexp.exec(jQuery('.details .edit-attachment').attr('href'));
89
  jQuery('.edit-attachment.crop-image').remove();
90
- jQuery('.details .edit-attachment').after( '<a class="thickbox mic-link edit-attachment crop-image" rel="crop" title="Crop" href="' + ajaxurl + '?action=mic_editor_window&postId=' + match[1] + '">Crop Image</a>' );
91
  } catch (e) {
92
  console.log(e);
93
  }
@@ -95,11 +99,11 @@ setInterval(function() {
95
  }, 500);
96
  });
97
  </script>
98
- <?php
99
  }
100
 
101
  /**
102
- * Ads link in the ligthbox media library
103
  */
104
  public function addAfterUploadAttachementEditLink() {
105
  ?>
@@ -114,7 +118,7 @@ setInterval(function() {
114
  var mRegexp = /\?post=([0-9]+)/;
115
  var match = mRegexp.exec(jQuery(this).attr('href'));
116
  if (!jQuery(this).parent().find('.edit-attachment.crop-image').length && jQuery(this).parent().find('.pinkynail').attr('src').match(/upload/g)) {
117
- jQuery(this).after( '<a class="thickbox mic-link edit-attachment crop-image" rel="crop" title="Crop" href="' + ajaxurl + '?action=mic_editor_window&postId=' + match[1] + '">Crop Image</a>' );
118
  }
119
  } catch (e) {
120
  console.log(e);
@@ -126,22 +130,24 @@ setInterval(function() {
126
  </script>
127
  <?php
128
  }
129
-
130
  /**
131
- * Crops the image based on $_POST array
132
  */
133
  public function cropImage() {
134
  global $_wp_additional_image_sizes;
135
 
136
  $uploadsDir = wp_upload_dir();
137
-
138
  $src_file_url = wp_get_attachment_image_src($_POST['attachmentId'], 'full');
 
139
  if (!$src_file_url) {
140
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
141
  exit;
142
  }
 
143
  $src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
144
-
145
  $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
146
  if (!$dst_file_url) {
147
  echo json_encode (array('status' => 'error', 'message' => 'wrong size' ) );
@@ -149,6 +155,7 @@ setInterval(function() {
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
 
@@ -161,7 +168,8 @@ setInterval(function() {
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']);
@@ -174,17 +182,27 @@ setInterval(function() {
174
  echo json_encode (array('status' => 'error', 'message' => 'wrong dimensions' ) );
175
  exit;
176
  }
177
-
 
178
  $dst_x = 0;
179
  $dst_y = 0;
180
-
181
  $src_x = max(0, $_POST['select']['x']) * $_POST['previewScale'];
182
  $src_y = max(0, $_POST['select']['y']) * $_POST['previewScale'];
183
  $src_w = max(0, $_POST['select']['w']) * $_POST['previewScale'];
184
  $src_h = max(0, $_POST['select']['h']) * $_POST['previewScale'];
185
 
 
 
 
 
 
 
 
 
 
 
 
186
  $ext = pathinfo($src_file, PATHINFO_EXTENSION);
187
-
188
  if ($ext == "gif"){
189
  $src_img = imagecreatefromgif($src_file);
190
  } else if($ext =="png"){
@@ -194,7 +212,7 @@ setInterval(function() {
194
  }
195
  $dst_img = imagecreatetruecolor($dst_w, $dst_h);
196
  imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
197
-
198
  if ($ext == "gif"){
199
  imagegif($dst_img, $dst_file);
200
  } else if($ext =="png"){
@@ -202,7 +220,8 @@ setInterval(function() {
202
  } else {
203
  imagejpeg($dst_img, $dst_file, 80);
204
  }
205
-
 
206
  echo json_encode (array('status' => 'ok', 'file' => $dst_file_url[0] . '?' . time() ) );
207
  exit;
208
  }
1
  <?php
2
+ /**
3
+ * Class responsible for all the logic
4
+ * @author tomasz
5
+ *
6
+ */
7
  class ManualImageCrop {
8
 
9
  private static $instance;
27
  * Enqueues all necessary CSS and Scripts
28
  */
29
  public function enqueueAssets() {
30
+ add_thickbox();
31
+
32
  wp_register_style( 'rct-admin', plugins_url('assets/css/mic-admin.css', dirname( __FILE__ ) ) );
33
  wp_enqueue_style( 'rct-admin' );
34
 
44
  * Hooks Editor Links into proper places
45
  */
46
  public function addEditorLinks() {
 
47
  add_action( 'media_row_actions', array($this, 'addMediaEditorLinks'), 10, 2 );
48
  add_action( 'admin_post_thumbnail_html', array($this, 'addCropFeatureImageEditorLink'), 10, 2 );
49
  add_action( 'print_media_templates', array($this, 'addAttachementEditLink') );
55
  */
56
  public function addMediaEditorLinks($links, $post) {
57
  if (preg_match('/image/', $post->post_mime_type)) {
58
+ $links['crop'] = '<a class="thickbox mic-link" rel="crop" title="Manual Image Crop" href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&postId=' . $post->ID . '">Crop</a>';
59
  }
60
  return $links;
61
  }
64
  * Adds link below "Remoce feature image" in post editing form
65
  */
66
  public function addCropFeatureImageEditorLink($content, $post) {
67
+ $content .= '<a id="micCropFeatureImage" class="thickbox mic-link" rel="crop" title="Manual Image Crop" href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&postId=' . get_post_thumbnail_id($post) . '">Crop featured image</a>
68
  <script>
69
  setInterval(function() {
70
  if (jQuery(\'#remove-post-thumbnail\').is(\':visible\')) {
78
  }
79
 
80
  /**
81
+ * Adds link in the ligthbox media library
82
  */
83
+ public function addAttachementEditLink() { ?>
 
 
84
  <script>
85
  var micEditAttachemtnLinkAdded = false;
86
  var micEditAttachemtnLinkAddedInterval = 0;
91
  var mRegexp = /\?post=([0-9]+)/;
92
  var match = mRegexp.exec(jQuery('.details .edit-attachment').attr('href'));
93
  jQuery('.edit-attachment.crop-image').remove();
94
+ jQuery('.details .edit-attachment').after( '<a class="thickbox mic-link edit-attachment crop-image" rel="crop" title="Manual Image Crop" href="' + ajaxurl + '?action=mic_editor_window&postId=' + match[1] + '">Crop Image</a>' );
95
  } catch (e) {
96
  console.log(e);
97
  }
99
  }, 500);
100
  });
101
  </script>
102
+ <?php
103
  }
104
 
105
  /**
106
+ * Adds link in the ligthbox media library
107
  */
108
  public function addAfterUploadAttachementEditLink() {
109
  ?>
118
  var mRegexp = /\?post=([0-9]+)/;
119
  var match = mRegexp.exec(jQuery(this).attr('href'));
120
  if (!jQuery(this).parent().find('.edit-attachment.crop-image').length && jQuery(this).parent().find('.pinkynail').attr('src').match(/upload/g)) {
121
+ jQuery(this).after( '<a class="thickbox mic-link edit-attachment crop-image" rel="crop" title="Manual Image Crop" href="' + ajaxurl + '?action=mic_editor_window&postId=' + match[1] + '">Crop Image</a>' );
122
  }
123
  } catch (e) {
124
  console.log(e);
130
  </script>
131
  <?php
132
  }
133
+
134
  /**
135
+ * Crops the image based on params passed in $_POST array
136
  */
137
  public function cropImage() {
138
  global $_wp_additional_image_sizes;
139
 
140
  $uploadsDir = wp_upload_dir();
141
+
142
  $src_file_url = wp_get_attachment_image_src($_POST['attachmentId'], 'full');
143
+
144
  if (!$src_file_url) {
145
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
146
  exit;
147
  }
148
+
149
  $src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
150
+
151
  $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
152
  if (!$dst_file_url) {
153
  echo json_encode (array('status' => 'error', 'message' => 'wrong size' ) );
155
  }
156
  $dst_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $dst_file_url[0]);
157
 
158
+ //checks if the destination image file is present (if it's not, we want to create a new file, as the WordPress returns the original image instead of specific one)
159
  if ($dst_file == $src_file) {
160
  $attachmentData = wp_generate_attachment_metadata( $_POST['attachmentId'], $dst_file );
161
 
168
  //retirives the new url to file (needet to refresh the preview)
169
  $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
170
  }
171
+
172
+ //sets the destination image dimensions
173
  if (isset($_wp_additional_image_sizes[$_POST['editedSize']])) {
174
  $dst_w = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['width']), $_POST['select']['w'] * $_POST['previewScale']);;
175
  $dst_h = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['height']), $_POST['select']['h'] * $_POST['previewScale']);
182
  echo json_encode (array('status' => 'error', 'message' => 'wrong dimensions' ) );
183
  exit;
184
  }
185
+
186
+ //prepares coordinates that will be passed to cropping function
187
  $dst_x = 0;
188
  $dst_y = 0;
 
189
  $src_x = max(0, $_POST['select']['x']) * $_POST['previewScale'];
190
  $src_y = max(0, $_POST['select']['y']) * $_POST['previewScale'];
191
  $src_w = max(0, $_POST['select']['w']) * $_POST['previewScale'];
192
  $src_h = max(0, $_POST['select']['h']) * $_POST['previewScale'];
193
 
194
+ //saves the selected area
195
+ $imageMetadata = wp_get_attachment_metadata($_POST['attachmentId']);
196
+ $imageMetadata['micSelectedArea'][$_POST['editedSize']] = array(
197
+ 'x' => $_POST['select']['x'],
198
+ 'y' => $_POST['select']['y'],
199
+ 'w' => $_POST['select']['w'],
200
+ 'h' => $_POST['select']['h'],
201
+ );
202
+ wp_update_attachment_metadata($_POST['attachmentId'], $imageMetadata);
203
+
204
+ //determines what's the image format
205
  $ext = pathinfo($src_file, PATHINFO_EXTENSION);
 
206
  if ($ext == "gif"){
207
  $src_img = imagecreatefromgif($src_file);
208
  } else if($ext =="png"){
212
  }
213
  $dst_img = imagecreatetruecolor($dst_w, $dst_h);
214
  imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
215
+
216
  if ($ext == "gif"){
217
  imagegif($dst_img, $dst_file);
218
  } else if($ext =="png"){
220
  } else {
221
  imagejpeg($dst_img, $dst_file, 80);
222
  }
223
+
224
+ //returns the url to the generated image (to allow refreshing the preview)
225
  echo json_encode (array('status' => 'ok', 'file' => $dst_file_url[0] . '?' . time() ) );
226
  exit;
227
  }
lib/ManualImageCropEditorWindow.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  class ManualImageCropEditorWindow {
3
 
4
  private static $instance;
@@ -24,9 +29,9 @@ class ManualImageCropEditorWindow {
24
  <h2 class="nav-tab-wrapper">
25
  Pick the image size: <?php
26
  global $_wp_additional_image_sizes;
27
-
28
  $imageSizes = get_intermediate_image_sizes();
29
-
30
  $editedSize = isset( $_GET['size'] ) ? $_GET['size'] : $imageSizes[0];
31
 
32
  foreach ($imageSizes as $s) {
@@ -44,6 +49,7 @@ class ManualImageCropEditorWindow {
44
  </h2>
45
  <div class="mic-left-col">
46
  <?php
 
47
  if (isset($_wp_additional_image_sizes[$editedSize])) {
48
  $width = intval($_wp_additional_image_sizes[$editedSize]['width']);
49
  $height = intval($_wp_additional_image_sizes[$editedSize]['height']);
@@ -55,7 +61,9 @@ class ManualImageCropEditorWindow {
55
  }
56
 
57
  $uploadsDir = wp_upload_dir();
58
-
 
 
59
  $src_file_url = wp_get_attachment_image_src($_GET['postId'], 'full');
60
  if (!$src_file_url) {
61
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
@@ -63,7 +71,7 @@ class ManualImageCropEditorWindow {
63
  }
64
  $src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
65
  $sizes = getimagesize($src_file);
66
-
67
  $previewWidth = min($sizes[0], 500);
68
  $previewHeight = min($sizes[1], 350);
69
  $previewRatio = 1;
@@ -148,8 +156,12 @@ class ManualImageCropEditorWindow {
148
  onSelect: showPreview,
149
  minSize: [<?php echo $minWidth; ?>, <?php echo $minHeight; ?>],
150
  maxSize: [<?php echo $previewWidth; ?>, <?php echo $previewHeight; ?>],
 
 
 
 
 
151
  aspectRatio: <?php echo $aspectRatio; ?>,
152
- setSelect: [<?php echo max(0, ($previewWidth - ($previewHeight * $aspectRatio)) / 2) ?>, <?php echo max(0, ($previewHeight - ($previewWidth / $aspectRatio)) / 2) ?>, <?php echo $previewWidth * $aspectRatio; ?>, <?php echo $previewHeight; ?>]
153
  }, function() {
154
  jcrop_api = this;
155
  });
1
  <?php
2
+ /**
3
+ * Class responsible for rendering the cropping Window
4
+ * @author tomasz
5
+ *
6
+ */
7
  class ManualImageCropEditorWindow {
8
 
9
  private static $instance;
29
  <h2 class="nav-tab-wrapper">
30
  Pick the image size: <?php
31
  global $_wp_additional_image_sizes;
32
+
33
  $imageSizes = get_intermediate_image_sizes();
34
+
35
  $editedSize = isset( $_GET['size'] ) ? $_GET['size'] : $imageSizes[0];
36
 
37
  foreach ($imageSizes as $s) {
49
  </h2>
50
  <div class="mic-left-col">
51
  <?php
52
+ //reads the specific registered image size dimension
53
  if (isset($_wp_additional_image_sizes[$editedSize])) {
54
  $width = intval($_wp_additional_image_sizes[$editedSize]['width']);
55
  $height = intval($_wp_additional_image_sizes[$editedSize]['height']);
61
  }
62
 
63
  $uploadsDir = wp_upload_dir();
64
+
65
+ $metaData = wp_get_attachment_metadata($_GET['postId']);
66
+
67
  $src_file_url = wp_get_attachment_image_src($_GET['postId'], 'full');
68
  if (!$src_file_url) {
69
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
71
  }
72
  $src_file = str_replace($uploadsDir['baseurl'], $uploadsDir['basedir'], $src_file_url[0]);
73
  $sizes = getimagesize($src_file);
74
+
75
  $previewWidth = min($sizes[0], 500);
76
  $previewHeight = min($sizes[1], 350);
77
  $previewRatio = 1;
156
  onSelect: showPreview,
157
  minSize: [<?php echo $minWidth; ?>, <?php echo $minHeight; ?>],
158
  maxSize: [<?php echo $previewWidth; ?>, <?php echo $previewHeight; ?>],
159
+ <?php if ( isset( $metaData['micSelectedArea'][$editedSize] ) ) { ?>
160
+ setSelect: [<?php echo max(0, $metaData['micSelectedArea'][$editedSize]['x']) ?>, <?php echo max(0, $metaData['micSelectedArea'][$editedSize]['y']) ?>, <?php echo max(0, $metaData['micSelectedArea'][$editedSize]['x']) + $metaData['micSelectedArea'][$editedSize]['w']; ?>, <?php echo max(0, $metaData['micSelectedArea'][$editedSize]['y']) + $metaData['micSelectedArea'][$editedSize]['h']; ?>],
161
+ <?php }else { ?>
162
+ setSelect: [<?php echo max(0, ($previewWidth - ($previewHeight * $aspectRatio)) / 2) ?>, <?php echo max(0, ($previewHeight - ($previewWidth / $aspectRatio)) / 2) ?>, <?php echo $previewWidth * $aspectRatio; ?>, <?php echo $previewHeight; ?>],
163
+ <?php }?>
164
  aspectRatio: <?php echo $aspectRatio; ?>,
 
165
  }, function() {
166
  jcrop_api = this;
167
  });
manual-image-crop.php CHANGED
@@ -3,19 +3,25 @@
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
10
  */
11
 
12
- define('mic_VERSION', '1.02');
13
 
14
  include_once(dirname(__FILE__) . '/lib/ManualImageCrop.php');
15
  include_once(dirname(__FILE__) . '/lib/ManualImageCropEditorWindow.php');
16
 
17
  //mic - stands for Manual Image Crop
18
 
 
 
 
 
 
 
19
  function mic_init_plugin() {
20
  if (! is_admin()) {
21
  //we are gonna use our plugin in the admin area only, so ends here if it's a frontend
@@ -23,7 +29,7 @@ function mic_init_plugin() {
23
  }
24
 
25
  $ManualImageCrop = ManualImageCrop::getInstance();
26
- add_action( 'admin_head', array($ManualImageCrop, 'enqueueAssets') );
27
  $ManualImageCrop->addEditorLinks();
28
 
29
  //attach admin actions
@@ -31,17 +37,21 @@ function mic_init_plugin() {
31
  add_action('wp_ajax_mic_crop_image', 'mic_ajax_crop_image');
32
  }
33
 
 
 
 
34
  function mic_ajax_editor_window() {
35
  $ManualImageCropEditorWindow = ManualImageCropEditorWindow::getInstance();
36
- add_action( 'admin_head', array(ManualImageCropEditorWindow, 'enqueueAssets') );
37
  $ManualImageCropEditorWindow->renderWindow();
38
  exit;
39
  }
40
 
 
 
 
41
  function mic_ajax_crop_image() {
42
  $ManualImageCrop = ManualImageCrop::getInstance();
43
  $ManualImageCrop->cropImage();
44
  exit;
45
  }
46
-
47
- add_action('plugins_loaded', 'mic_init_plugin');
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.04
7
  Author: Tomasz Sita
8
  Author URI: http://www.rocketmill.co.uk/author/tomasz
9
  License: GPL2
10
  */
11
 
12
+ define('mic_VERSION', '1.04');
13
 
14
  include_once(dirname(__FILE__) . '/lib/ManualImageCrop.php');
15
  include_once(dirname(__FILE__) . '/lib/ManualImageCropEditorWindow.php');
16
 
17
  //mic - stands for Manual Image Crop
18
 
19
+
20
+ add_action('plugins_loaded', 'mic_init_plugin');
21
+
22
+ /**
23
+ * inits the plugin
24
+ */
25
  function mic_init_plugin() {
26
  if (! is_admin()) {
27
  //we are gonna use our plugin in the admin area only, so ends here if it's a frontend
29
  }
30
 
31
  $ManualImageCrop = ManualImageCrop::getInstance();
32
+ add_action( 'admin_enqueue_scripts', array($ManualImageCrop, 'enqueueAssets') );
33
  $ManualImageCrop->addEditorLinks();
34
 
35
  //attach admin actions
37
  add_action('wp_ajax_mic_crop_image', 'mic_ajax_crop_image');
38
  }
39
 
40
+ /**
41
+ * ajax call rendering the image cropping area
42
+ */
43
  function mic_ajax_editor_window() {
44
  $ManualImageCropEditorWindow = ManualImageCropEditorWindow::getInstance();
 
45
  $ManualImageCropEditorWindow->renderWindow();
46
  exit;
47
  }
48
 
49
+ /**
50
+ * ajax call that does the cropping job and overrides the previous image version
51
+ */
52
  function mic_ajax_crop_image() {
53
  $ManualImageCrop = ManualImageCrop::getInstance();
54
  $ManualImageCrop->cropImage();
55
  exit;
56
  }
57
+ ;
 
readme.txt CHANGED
@@ -2,16 +2,15 @@
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
 
12
 
13
  == Description ==
14
-
15
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
16
  Simply click on the "Crop" link next to any image in your media library.
17
  The "lightbox" style interface will be brought up and you are ready to go.
@@ -35,6 +34,10 @@ Automatically:
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
 
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.1
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ Stable tag: 1.04
9
 
10
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
11
 
12
 
13
  == Description ==
 
14
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
15
  Simply click on the "Crop" link next to any image in your media library.
16
  The "lightbox" style interface will be brought up and you are ready to go.
34
 
35
  == Changelog ==
36
 
37
+ = 1.04 =
38
+ * Added remembering of the previously selected area after cropping the specific image size
39
+ * Fixed the "wp_enqueue_script was called incorrectly" warning in the WP debug mode
40
+
41
  = 1.03 =
42
  * Fixed the issue with overwriting the original image when cropping image size registered after the attachment had been uploaded
43