Manual Image Crop - Version 1.11

Version Description

  • Hungarian translation added
  • Swedish translation added
  • Security improvements
Download this release

Release Info

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

Code changes from version 1.10 to 1.11

languages/microp-hu_HU.mo ADDED
Binary file
languages/microp-hu_HU.po ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Manual Image Crop\n"
4
+ "POT-Creation-Date: 2015-08-24 23:01+0100\n"
5
+ "PO-Revision-Date: 2015-08-24 23:51+0100\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.4\n"
11
+ "X-Poedit-Basepath: D:/Programy/xampp/apps/wordpress/htdocs/wp-content/"
12
+ "plugins/manual-image-crop\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-KeywordsList: _e;__\n"
15
+ "Last-Translator: \n"
16
+ "Language: hu_HU\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: manual-image-crop.php:5
20
+ msgid ""
21
+ "Plugin allows you to manually crop all the image sizes registered in your "
22
+ "WordPress theme (in particular featured image). Simply click on the \"Crop\" "
23
+ "link next to any image in your media library and select the area of the "
24
+ "image you want to crop."
25
+ msgstr ""
26
+ "Ez a bővítmény lehetővé teszi hogy manuálisan kivágd es átméretezd az összes "
27
+ "regisztrált kép méretet a WordPress sablonban. Csak egyszerűen kattincs a "
28
+ "“Kivág” linkre bármelyik kép mellett a médiatárban és válaszd ki a kivágandó "
29
+ "feluletet."
30
+
31
+ #: lib/ManualImageCrop.php:58
32
+ msgid "Crop"
33
+ msgstr "Kivág"
34
+
35
+ #: lib/ManualImageCrop.php:67 lib/ManualImageCrop.php:94
36
+ #: lib/ManualImageCrop.php:104 lib/ManualImageCrop.php:131
37
+ #: lib/ManualImageCropSettingsPage.php:45
38
+ #: lib/ManualImageCropSettingsPage.php:46 manual-image-crop.php:3
39
+ msgid "Manual Image Crop"
40
+ msgstr "Manuális Kép Kivágó"
41
+
42
+ #: lib/ManualImageCrop.php:67
43
+ msgid "Crop featured image"
44
+ msgstr "Kiemelt kép kivágása:"
45
+
46
+ #: lib/ManualImageCrop.php:94 lib/ManualImageCrop.php:104
47
+ #: lib/ManualImageCrop.php:131
48
+ msgid "Crop Image"
49
+ msgstr "Kép kivágása:"
50
+
51
+ #: lib/ManualImageCropEditorWindow.php:30
52
+ msgid "Pick the image size:"
53
+ msgstr "Válassz kép méretet:"
54
+
55
+ #: lib/ManualImageCropEditorWindow.php:40
56
+ #: lib/ManualImageCropSettingsPage.php:133
57
+ msgid "Thumbnail"
58
+ msgstr "Bélyegkép"
59
+
60
+ #: lib/ManualImageCropEditorWindow.php:41
61
+ #: lib/ManualImageCropSettingsPage.php:134
62
+ msgid "Medium"
63
+ msgstr "Közepes"
64
+
65
+ #: lib/ManualImageCropEditorWindow.php:42
66
+ #: lib/ManualImageCropSettingsPage.php:135
67
+ msgid "Large"
68
+ msgstr "Nagy"
69
+
70
+ #: lib/ManualImageCropEditorWindow.php:43
71
+ #: lib/ManualImageCropSettingsPage.php:136
72
+ msgid "Full Size"
73
+ msgstr "Teljes méret"
74
+
75
+ #: lib/ManualImageCropEditorWindow.php:151
76
+ msgid "Original picture dimensions:"
77
+ msgstr "Eredeti kép méretei:"
78
+
79
+ #: lib/ManualImageCropEditorWindow.php:152
80
+ msgid "Target picture dimensions:"
81
+ msgstr "Végleges kép méretei:"
82
+
83
+ #: lib/ManualImageCropEditorWindow.php:156
84
+ msgid "Soft proportional crop mode"
85
+ msgstr "Arányos kivágás"
86
+
87
+ #: lib/ManualImageCropEditorWindow.php:156
88
+ msgid "Hard crop mode"
89
+ msgstr "Aránytalan kivágás"
90
+
91
+ #: lib/ManualImageCropEditorWindow.php:160
92
+ msgid "New image:"
93
+ msgstr "Új kép:"
94
+
95
+ #: lib/ManualImageCropEditorWindow.php:167
96
+ msgid "Previous image:"
97
+ msgstr "Előző kép:"
98
+
99
+ #: lib/ManualImageCropEditorWindow.php:175
100
+ msgid "Crop it!"
101
+ msgstr "Kivágás"
102
+
103
+ #: lib/ManualImageCropEditorWindow.php:182
104
+ msgid "Target JPEG Quality"
105
+ msgstr "Végleges JPEG Minőség"
106
+
107
+ #: lib/ManualImageCropEditorWindow.php:183
108
+ #: lib/ManualImageCropSettingsPage.php:172
109
+ msgid "100 (best quality, biggest file)"
110
+ msgstr "100 (legjobb, legnagyobb fájl)"
111
+
112
+ #: lib/ManualImageCropEditorWindow.php:184
113
+ #: lib/ManualImageCropSettingsPage.php:173
114
+ msgid "80 (very high quality)"
115
+ msgstr "80 (nagyon jó)"
116
+
117
+ #: lib/ManualImageCropEditorWindow.php:185
118
+ #: lib/ManualImageCropSettingsPage.php:174
119
+ msgid "70 (high quality)"
120
+ msgstr "70 (jobb)"
121
+
122
+ #: lib/ManualImageCropEditorWindow.php:186
123
+ #: lib/ManualImageCropSettingsPage.php:175
124
+ msgid "60 (good)"
125
+ msgstr "60 (jó)"
126
+
127
+ #: lib/ManualImageCropEditorWindow.php:187
128
+ #: lib/ManualImageCropSettingsPage.php:176
129
+ msgid "50 (average)"
130
+ msgstr "50 (átlagos)"
131
+
132
+ #: lib/ManualImageCropEditorWindow.php:188
133
+ #: lib/ManualImageCropSettingsPage.php:177
134
+ msgid "30 (low)"
135
+ msgstr "30 (alacsony)"
136
+
137
+ #: lib/ManualImageCropEditorWindow.php:189
138
+ #: lib/ManualImageCropSettingsPage.php:178
139
+ msgid "10 (very low, smallest file)"
140
+ msgstr "10 (nagyon alacson, legkissebb fájl)"
141
+
142
+ #: lib/ManualImageCropEditorWindow.php:196
143
+ msgid "Generate Retina/HiDPI (@2x):"
144
+ msgstr "Retina/HiDPI (@2x) generálása:"
145
+
146
+ #: lib/ManualImageCropEditorWindow.php:201
147
+ msgid "The image has been cropped successfully"
148
+ msgstr "A kép sikeresen átalakítva"
149
+
150
+ #: lib/ManualImageCropEditorWindow.php:202
151
+ msgid "An Error has occured. Please try again or contact plugin's author."
152
+ msgstr ""
153
+ "Hiba lépett fel. Kérem probálja újra vagy vegye fel a kapcsolatot a "
154
+ "bővítmény szerzőjével."
155
+
156
+ #: lib/ManualImageCropEditorWindow.php:245
157
+ msgid "Compatible"
158
+ msgstr "Kompatibilis"
159
+
160
+ #: lib/ManualImageCropEditorWindow.php:247
161
+ msgid "Source too small"
162
+ msgstr "Forrás túl kicsi"
163
+
164
+ #: lib/ManualImageCropSettingsPage.php:61
165
+ msgid "Manual Image Crop Settings"
166
+ msgstr "Manuális Kép Kivágó Beállítások"
167
+
168
+ #: lib/ManualImageCropSettingsPage.php:87
169
+ msgid "Mic Custom Settings"
170
+ msgstr "Manuális Kép Kivágó Egyéni Beállítások"
171
+
172
+ #: lib/ManualImageCropSettingsPage.php:94
173
+ msgid "Crop sizes settings"
174
+ msgstr "Méret beállítások"
175
+
176
+ #: lib/ManualImageCropSettingsPage.php:120
177
+ msgid "Enter your settings below:"
178
+ msgstr "Adja meg a beállításait"
179
+
180
+ #: lib/ManualImageCropSettingsPage.php:143
181
+ msgid "Size"
182
+ msgstr "Méret"
183
+
184
+ #: lib/ManualImageCropSettingsPage.php:144
185
+ msgid "Visible"
186
+ msgstr "Látható"
187
+
188
+ #: lib/ManualImageCropSettingsPage.php:145
189
+ msgid "Default JPEG Quality"
190
+ msgstr "Alapértelmezett JPEG Minőség"
191
+
192
+ #: lib/ManualImageCropSettingsPage.php:146
193
+ msgid "Custom Label"
194
+ msgstr "Egyéni címke"
195
+
196
+ #: lib/ManualImageCropSettingsPage.php:168
197
+ msgid "Yes"
198
+ msgstr "Igen"
199
+
200
+ #: lib/ManualImageCropSettingsPage.php:169
201
+ msgid "No"
202
+ msgstr "Nem"
languages/microp-sv_SE.mo ADDED
Binary file
languages/microp-sv_SE.po ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Manual Image Crop\n"
4
+ "POT-Creation-Date: 2015-05-01 00:50+0100\n"
5
+ "PO-Revision-Date: 2015-07-09 20:07+0100\n"
6
+ "Last-Translator: KO. Mattsson <karloskar@ponty.se>\n"
7
+ "Language-Team: \n"
8
+ "Language: sv_SE\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: \n"
13
+ "X-Poedit-Basepath: D:\\Programy\\xampp\\apps\\wordpress\\htdocs\\wp-content"
14
+ "\\plugins\\manual-image-crop\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-KeywordsList: _e;__\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: manual-image-crop.php:5
20
+ msgid ""
21
+ "Plugin allows you to manually crop all the image sizes registered in your "
22
+ "WordPress theme (in particular featured image). Simply click on the \"Crop\" "
23
+ "link next to any image in your media library and select the area of the "
24
+ "image you want to crop."
25
+ msgstr ""
26
+ "Tillägget ger dig möjlighet att manuellt beskära alla bildstorlekar som "
27
+ "registrerats i ditt WordPress-tema (särskilt utvalda bilder). Klicka bara på "
28
+ "\"Beskär\" bredvid en bild i media-biblioteket och välj område som du vill "
29
+ "beskära till."
30
+
31
+ #: lib/ManualImageCrop.php:58
32
+ msgid "Crop"
33
+ msgstr "Beskär"
34
+
35
+ #: lib/ManualImageCrop.php:67 lib/ManualImageCrop.php:94
36
+ #: lib/ManualImageCrop.php:104 lib/ManualImageCrop.php:131
37
+ #: lib/ManualImageCropSettingsPage.php:45
38
+ #: lib/ManualImageCropSettingsPage.php:46 manual-image-crop.php:3
39
+ msgid "Manual Image Crop"
40
+ msgstr "Manuell bildbeskärning"
41
+
42
+ #: lib/ManualImageCrop.php:67
43
+ msgid "Crop featured image"
44
+ msgstr "Beskär utvald bild"
45
+
46
+ #: lib/ManualImageCrop.php:94 lib/ManualImageCrop.php:104
47
+ #: lib/ManualImageCrop.php:131
48
+ msgid "Crop Image"
49
+ msgstr "Beskär bild"
50
+
51
+ #: lib/ManualImageCropEditorWindow.php:30
52
+ msgid "Pick the image size:"
53
+ msgstr "Välj bildstorlek:"
54
+
55
+ #: lib/ManualImageCropEditorWindow.php:40
56
+ #: lib/ManualImageCropSettingsPage.php:133
57
+ msgid "Thumbnail"
58
+ msgstr "Miniatyr"
59
+
60
+ #: lib/ManualImageCropEditorWindow.php:41
61
+ #: lib/ManualImageCropSettingsPage.php:134
62
+ msgid "Medium"
63
+ msgstr "Medium"
64
+
65
+ #: lib/ManualImageCropEditorWindow.php:42
66
+ #: lib/ManualImageCropSettingsPage.php:135
67
+ msgid "Large"
68
+ msgstr "Large"
69
+
70
+ #: lib/ManualImageCropEditorWindow.php:43
71
+ #: lib/ManualImageCropSettingsPage.php:136
72
+ msgid "Full Size"
73
+ msgstr "Full storlek"
74
+
75
+ #: lib/ManualImageCropEditorWindow.php:151
76
+ msgid "Original picture dimensions:"
77
+ msgstr "Ursprungliga bilddimensioner:"
78
+
79
+ #: lib/ManualImageCropEditorWindow.php:152
80
+ msgid "Target picture dimensions:"
81
+ msgstr "Bilddimensioner i ändrad bild:"
82
+
83
+ #: lib/ManualImageCropEditorWindow.php:156
84
+ msgid "Soft proportional crop mode"
85
+ msgstr "Mjukt proportionellt beskärningssätt"
86
+
87
+ #: lib/ManualImageCropEditorWindow.php:156
88
+ msgid "Hard crop mode"
89
+ msgstr "Hårt beskärningssätt"
90
+
91
+ #: lib/ManualImageCropEditorWindow.php:160
92
+ msgid "New image:"
93
+ msgstr "Ny bild:"
94
+
95
+ #: lib/ManualImageCropEditorWindow.php:167
96
+ msgid "Previous image:"
97
+ msgstr "Föregående bild:"
98
+
99
+ #: lib/ManualImageCropEditorWindow.php:175
100
+ msgid "Crop it!"
101
+ msgstr "Beskär!"
102
+
103
+ #: lib/ManualImageCropEditorWindow.php:182
104
+ msgid "Target JPEG Quality"
105
+ msgstr "Målets JPEG-kvalité"
106
+
107
+ #: lib/ManualImageCropEditorWindow.php:183
108
+ #: lib/ManualImageCropSettingsPage.php:172
109
+ msgid "100 (best quality, biggest file)"
110
+ msgstr "100 (högst kvalité, störst filstorlek)"
111
+
112
+ #: lib/ManualImageCropEditorWindow.php:184
113
+ #: lib/ManualImageCropSettingsPage.php:173
114
+ msgid "80 (very high quality)"
115
+ msgstr "80 (mycket hög kvalité)"
116
+
117
+ #: lib/ManualImageCropEditorWindow.php:185
118
+ #: lib/ManualImageCropSettingsPage.php:174
119
+ msgid "70 (high quality)"
120
+ msgstr "70 (hög kvalité)"
121
+
122
+ #: lib/ManualImageCropEditorWindow.php:186
123
+ #: lib/ManualImageCropSettingsPage.php:175
124
+ msgid "60 (good)"
125
+ msgstr "60 (bra)"
126
+
127
+ #: lib/ManualImageCropEditorWindow.php:187
128
+ #: lib/ManualImageCropSettingsPage.php:176
129
+ msgid "50 (average)"
130
+ msgstr "50 (medelmåttig)"
131
+
132
+ #: lib/ManualImageCropEditorWindow.php:188
133
+ #: lib/ManualImageCropSettingsPage.php:177
134
+ msgid "30 (low)"
135
+ msgstr "30 (låg)"
136
+
137
+ #: lib/ManualImageCropEditorWindow.php:189
138
+ #: lib/ManualImageCropSettingsPage.php:178
139
+ msgid "10 (very low, smallest file)"
140
+ msgstr "10 (väldigt låg, minst filstorlek)"
141
+
142
+ #: lib/ManualImageCropEditorWindow.php:196
143
+ msgid "Generate Retina/HiDPI (@2x):"
144
+ msgstr "Skapa Retina/HiDPI (@2x):"
145
+
146
+ #: lib/ManualImageCropEditorWindow.php:201
147
+ msgid "The image has been cropped successfully"
148
+ msgstr "Bilden har beskurits med framgång"
149
+
150
+ #: lib/ManualImageCropEditorWindow.php:202
151
+ msgid "An Error has occured. Please try again or contact plugin's author."
152
+ msgstr ""
153
+ "Ett fel har inträttat. Var vänlig försök igen eller kontakta tilläggets "
154
+ "skapare."
155
+
156
+ #: lib/ManualImageCropEditorWindow.php:245
157
+ msgid "Compatible"
158
+ msgstr "Kompatibel"
159
+
160
+ #: lib/ManualImageCropEditorWindow.php:247
161
+ msgid "Source too small"
162
+ msgstr "Källfilen är för liten"
163
+
164
+ #: lib/ManualImageCropSettingsPage.php:61
165
+ msgid "Manual Image Crop Settings"
166
+ msgstr "Inställningar för manuell bildbeskärning"
167
+
168
+ #: lib/ManualImageCropSettingsPage.php:87
169
+ msgid "Mic Custom Settings"
170
+ msgstr "Mic Custom Settings"
171
+
172
+ #: lib/ManualImageCropSettingsPage.php:94
173
+ msgid "Crop sizes settings"
174
+ msgstr "Inställningar för beskärnings-storlekar"
175
+
176
+ #: lib/ManualImageCropSettingsPage.php:120
177
+ msgid "Enter your settings below:"
178
+ msgstr "Fyll i dina inställningar nedan:"
179
+
180
+ #: lib/ManualImageCropSettingsPage.php:143
181
+ msgid "Size"
182
+ msgstr "Storlek"
183
+
184
+ #: lib/ManualImageCropSettingsPage.php:144
185
+ msgid "Visible"
186
+ msgstr "Synlig"
187
+
188
+ #: lib/ManualImageCropSettingsPage.php:145
189
+ msgid "Default JPEG Quality"
190
+ msgstr "Förinställt värde JPEG-kvalité"
191
+
192
+ #: lib/ManualImageCropSettingsPage.php:146
193
+ msgid "Custom Label"
194
+ msgstr "Egen etikett"
195
+
196
+ #: lib/ManualImageCropSettingsPage.php:168
197
+ msgid "Yes"
198
+ msgstr "Ja"
199
+
200
+ #: lib/ManualImageCropSettingsPage.php:169
201
+ msgid "No"
202
+ msgstr "Nej"
lib/ManualImageCrop.php CHANGED
@@ -140,14 +140,45 @@ class ManualImageCrop {
140
  </script>
141
  <?php
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  /**
145
  * Crops the image based on params passed in $_POST array
146
  */
147
  public function cropImage() {
148
  global $_wp_additional_image_sizes;
 
 
149
 
150
- $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
151
 
152
  if (!$dst_file_url) {
153
  exit;
@@ -163,10 +194,10 @@ class ManualImageCrop {
163
 
164
  if ( function_exists( '_load_image_to_edit_path' ) ) {
165
  // this function is consider as private, but it return proper image path. Notice it is in function_exists condition
166
- $src_file = _load_image_to_edit_path( $_POST['attachmentId'], 'full' );
167
- $dst_file = _load_image_to_edit_path( $_POST['attachmentId'], $_POST['editedSize'] );
168
  } else {
169
- $src_file_url = wp_get_attachment_image_src( $_POST['attachmentId'], 'full' );
170
 
171
  if ( ! $src_file_url ) {
172
  echo json_encode( array( 'status' => 'error', 'message' => 'wrong attachment' ) );
@@ -179,31 +210,31 @@ class ManualImageCrop {
179
 
180
  //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)
181
  if ($dst_file == $src_file) {
182
- $attachmentData = wp_generate_attachment_metadata( $_POST['attachmentId'], $dst_file );
183
 
184
  //overwrite with previous values
185
- $prevAttachmentData = wp_get_attachment_metadata($_POST['attachmentId']);
186
  if (isset($prevAttachmentData['micSelectedArea'])) {
187
  $attachmentData['micSelectedArea'] = $prevAttachmentData['micSelectedArea'];
188
  }
189
 
190
  //saves new path to the image size in the database
191
- wp_update_attachment_metadata( $_POST['attachmentId'], $attachmentData );
192
 
193
  //new destination file path - replaces original file name with the correct one
194
- $dst_file = str_replace( basename($attachmentData['file']), $attachmentData['sizes'][ $_POST['editedSize'] ]['file'], $dst_file);
195
 
196
  //retrieves the new url to file (needet to refresh the preview)
197
- $dst_file_url = wp_get_attachment_image_src($_POST['attachmentId'], $_POST['editedSize']);
198
  }
199
 
200
  //sets the destination image dimensions
201
- if (isset($_wp_additional_image_sizes[$_POST['editedSize']])) {
202
- $dst_w = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['width']), $_POST['select']['w'] * $_POST['previewScale']);
203
- $dst_h = min(intval($_wp_additional_image_sizes[$_POST['editedSize']]['height']), $_POST['select']['h'] * $_POST['previewScale']);
204
  } else {
205
- $dst_w = min(get_option($_POST['editedSize'].'_size_w'), $_POST['select']['w'] * $_POST['previewScale']);
206
- $dst_h = min(get_option($_POST['editedSize'].'_size_h'), $_POST['select']['h'] * $_POST['previewScale']);
207
  }
208
 
209
  if (!$dst_w || !$dst_h) {
@@ -214,10 +245,10 @@ class ManualImageCrop {
214
  //prepares coordinates that will be passed to cropping function
215
  $dst_x = 0;
216
  $dst_y = 0;
217
- $src_x = max(0, $_POST['select']['x']) * $_POST['previewScale'];
218
- $src_y = max(0, $_POST['select']['y']) * $_POST['previewScale'];
219
- $src_w = max(0, $_POST['select']['w']) * $_POST['previewScale'];
220
- $src_h = max(0, $_POST['select']['h']) * $_POST['previewScale'];
221
 
222
  $size = wp_get_image_editor( $src_file )->get_size();
223
 
@@ -238,17 +269,15 @@ class ManualImageCrop {
238
  }
239
 
240
  //saves the selected area
241
- $imageMetadata = wp_get_attachment_metadata($_POST['attachmentId']);
242
- $imageMetadata['micSelectedArea'][$_POST['editedSize']] = array(
243
- 'x' => $_POST['select']['x'],
244
- 'y' => $_POST['select']['y'],
245
- 'w' => $_POST['select']['w'],
246
- 'h' => $_POST['select']['h'],
247
- 'scale' => $_POST['previewScale'],
248
  );
249
- wp_update_attachment_metadata($_POST['attachmentId'], $imageMetadata);
250
-
251
- $quality = isset($_POST['mic_quality']) ? intval($_POST['mic_quality']) : 60;
252
 
253
  if ( function_exists('wp_get_image_editor') ) {
254
  $img = wp_get_image_editor( $src_file );
@@ -256,7 +285,7 @@ class ManualImageCrop {
256
  if ( ! is_wp_error( $img ) ) {
257
 
258
  $img->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, false );
259
- $img->set_quality( $quality );
260
  $saveStatus = $img->save( $dst_file );
261
 
262
  if ( is_wp_error( $saveStatus ) ) {
@@ -307,7 +336,7 @@ class ManualImageCrop {
307
  }
308
 
309
  // Generate Retina Image
310
- if( isset( $_POST['make2x'] ) && $_POST['make2x'] === 'true' ) {
311
  $dst_w2x = $dst_w * 2;
312
  $dst_h2x = $dst_h * 2;
313
 
@@ -352,8 +381,8 @@ class ManualImageCrop {
352
  }
353
  }
354
  // update 'mic_make2x' option status to persist choice
355
- if( isset( $_POST['make2x'] ) && $_POST['make2x'] !== get_option('mic_make2x') ) {
356
- update_option('mic_make2x', $_POST['make2x']);
357
  }
358
 
359
  //returns the url to the generated image (to allow refreshing the preview)
140
  </script>
141
  <?php
142
  }
143
+
144
+ private function filterPostData() {
145
+ $imageSizes = get_intermediate_image_sizes();
146
+
147
+ $data = array(
148
+ 'attachmentId' => filter_var($_POST['attachmentId'], FILTER_SANITIZE_NUMBER_INT),
149
+ 'editedSize' => in_array($_POST['editedSize'], $imageSizes) ? $_POST['editedSize'] : null,
150
+ 'select' => array(
151
+ 'x' => filter_var($_POST['select']['x'], FILTER_SANITIZE_NUMBER_INT),
152
+ 'y' => filter_var($_POST['select']['y'], FILTER_SANITIZE_NUMBER_INT),
153
+ 'w' => filter_var($_POST['select']['w'], FILTER_SANITIZE_NUMBER_INT),
154
+ 'h' => filter_var($_POST['select']['h'], FILTER_SANITIZE_NUMBER_INT),
155
+ ),
156
+ 'previewScale' => filter_var($_POST['previewScale'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)
157
+
158
+ );
159
+
160
+ if (isset($_POST['mic_quality'])) {
161
+ $data['mic_quality'] = filter_var($_POST['mic_quality'], FILTER_SANITIZE_NUMBER_INT);
162
+ } else {
163
+ $data['mic_quality'] = 60;
164
+ }
165
+
166
+ if (isset($_POST['make2x'])) {
167
+ $data['make2x'] = filter_var($_POST['make2x'], FILTER_VALIDATE_BOOLEAN);
168
+ }
169
+
170
+ return $data;
171
+ }
172
 
173
  /**
174
  * Crops the image based on params passed in $_POST array
175
  */
176
  public function cropImage() {
177
  global $_wp_additional_image_sizes;
178
+
179
+ $data = $this->filterPostData();
180
 
181
+ $dst_file_url = wp_get_attachment_image_src($data['attachmentId'], $data['editedSize']);
182
 
183
  if (!$dst_file_url) {
184
  exit;
194
 
195
  if ( function_exists( '_load_image_to_edit_path' ) ) {
196
  // this function is consider as private, but it return proper image path. Notice it is in function_exists condition
197
+ $src_file = _load_image_to_edit_path( $data['attachmentId'], 'full' );
198
+ $dst_file = _load_image_to_edit_path( $data['attachmentId'], $data['editedSize'] );
199
  } else {
200
+ $src_file_url = wp_get_attachment_image_src( $data['attachmentId'], 'full' );
201
 
202
  if ( ! $src_file_url ) {
203
  echo json_encode( array( 'status' => 'error', 'message' => 'wrong attachment' ) );
210
 
211
  //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)
212
  if ($dst_file == $src_file) {
213
+ $attachmentData = wp_generate_attachment_metadata( $data['attachmentId'], $dst_file );
214
 
215
  //overwrite with previous values
216
+ $prevAttachmentData = wp_get_attachment_metadata($data['attachmentId']);
217
  if (isset($prevAttachmentData['micSelectedArea'])) {
218
  $attachmentData['micSelectedArea'] = $prevAttachmentData['micSelectedArea'];
219
  }
220
 
221
  //saves new path to the image size in the database
222
+ wp_update_attachment_metadata( $data['attachmentId'], $attachmentData );
223
 
224
  //new destination file path - replaces original file name with the correct one
225
+ $dst_file = str_replace( basename($attachmentData['file']), $attachmentData['sizes'][ $data['editedSize'] ]['file'], $dst_file);
226
 
227
  //retrieves the new url to file (needet to refresh the preview)
228
+ $dst_file_url = wp_get_attachment_image_src($data['attachmentId'], $data['editedSize']);
229
  }
230
 
231
  //sets the destination image dimensions
232
+ if (isset($_wp_additional_image_sizes[$data['editedSize']])) {
233
+ $dst_w = min(intval($_wp_additional_image_sizes[$data['editedSize']]['width']), $data['select']['w'] * $data['previewScale']);
234
+ $dst_h = min(intval($_wp_additional_image_sizes[$data['editedSize']]['height']), $data['select']['h'] * $data['previewScale']);
235
  } else {
236
+ $dst_w = min(get_option($data['editedSize'].'_size_w'), $data['select']['w'] * $data['previewScale']);
237
+ $dst_h = min(get_option($data['editedSize'].'_size_h'), $data['select']['h'] * $data['previewScale']);
238
  }
239
 
240
  if (!$dst_w || !$dst_h) {
245
  //prepares coordinates that will be passed to cropping function
246
  $dst_x = 0;
247
  $dst_y = 0;
248
+ $src_x = max(0, $data['select']['x']) * $data['previewScale'];
249
+ $src_y = max(0, $data['select']['y']) * $data['previewScale'];
250
+ $src_w = max(0, $data['select']['w']) * $data['previewScale'];
251
+ $src_h = max(0, $data['select']['h']) * $data['previewScale'];
252
 
253
  $size = wp_get_image_editor( $src_file )->get_size();
254
 
269
  }
270
 
271
  //saves the selected area
272
+ $imageMetadata = wp_get_attachment_metadata($data['attachmentId']);
273
+ $imageMetadata['micSelectedArea'][$data['editedSize']] = array(
274
+ 'x' => $data['select']['x'],
275
+ 'y' => $data['select']['y'],
276
+ 'w' => $data['select']['w'],
277
+ 'h' => $data['select']['h'],
278
+ 'scale' => $data['previewScale'],
279
  );
280
+ wp_update_attachment_metadata($data['attachmentId'], $imageMetadata);
 
 
281
 
282
  if ( function_exists('wp_get_image_editor') ) {
283
  $img = wp_get_image_editor( $src_file );
285
  if ( ! is_wp_error( $img ) ) {
286
 
287
  $img->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, false );
288
+ $img->set_quality( $data['mic_quality'] );
289
  $saveStatus = $img->save( $dst_file );
290
 
291
  if ( is_wp_error( $saveStatus ) ) {
336
  }
337
 
338
  // Generate Retina Image
339
+ if( isset( $data['make2x'] ) && $data['make2x'] === 'true' ) {
340
  $dst_w2x = $dst_w * 2;
341
  $dst_h2x = $dst_h * 2;
342
 
381
  }
382
  }
383
  // update 'mic_make2x' option status to persist choice
384
+ if( isset( $data['make2x'] ) && $data['make2x'] !== get_option('mic_make2x') ) {
385
+ update_option('mic_make2x', $data['make2x']);
386
  }
387
 
388
  //returns the url to the generated image (to allow refreshing the preview)
lib/ManualImageCropEditorWindow.php CHANGED
@@ -36,8 +36,10 @@ class ManualImageCropEditorWindow {
36
 
37
  $imageSizes = get_intermediate_image_sizes();
38
 
39
- $editedSize = isset( $_GET['size'] ) ? $_GET['size'] : null;
40
 
 
 
41
  $sizeLabels = apply_filters( 'image_size_names_choose', array(
42
  'thumbnail' => __('Thumbnail'),
43
  'medium' => __('Medium'),
@@ -74,7 +76,7 @@ class ManualImageCropEditorWindow {
74
  // Get user defined label for the size or just cleanup a bit
75
  $label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
76
  $label = $sizesSettings[$s]['label'] ? $sizesSettings[$s]['label'] : $label;
77
- echo '<a href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&size=' . $s . '&postId=' . $_GET['postId'] . '&width=940" class="mic-icon-' . $s . ' rm-crop-size-tab nav-tab ' . ( ($s == $editedSize) ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
78
  }
79
  ?>
80
  </h2>
@@ -93,9 +95,9 @@ class ManualImageCropEditorWindow {
93
 
94
  $uploadsDir = wp_upload_dir();
95
 
96
- $metaData = wp_get_attachment_metadata($_GET['postId']);
97
 
98
- $src_file_url = wp_get_attachment_image_src($_GET['postId'], 'full');
99
  if (!$src_file_url) {
100
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
101
  exit;
@@ -156,7 +158,7 @@ class ManualImageCropEditorWindow {
156
 
157
  ?>
158
  <div style="margin: auto; width: <?php echo $previewWidth; ?>px;">
159
- <img style="width: <?php echo $previewWidth; ?>px; height: <?php echo $previewHeight; ?>px;" id="jcrop_target" src="<?php echo wp_get_attachment_url($_GET['postId']); ?>">
160
  </div>
161
  </div>
162
  <div class="mic-right-col">
@@ -180,13 +182,13 @@ class ManualImageCropEditorWindow {
180
  <br />
181
  <div style="width: <?php echo $smallPreviewWidth; ?>px; height: <?php echo $smallPreviewHeight; ?>px; overflow: hidden; margin-left: 5px; float: right;">
182
  <img id="preview"
183
- src="<?php echo wp_get_attachment_url($_GET['postId']); ?>">
184
  </div>
185
  </div>
186
 
187
  <div class="mic-48-col">
188
  <?php _e('Previous image:','microp');
189
- $editedImage = wp_get_attachment_image_src($_GET['postId'], $editedSize);
190
  ?>
191
  <div style="width: <?php echo $smallPreviewWidth; ?>px; height: <?php echo $smallPreviewHeight; ?>px; overflow: hidden; margin-left: 5px;">
192
  <img id="micPreviousImage" style="max-width: <?php echo $smallPreviewWidth; ?>px; max-height: <?php echo $smallPreviewHeight; ?>px;" src="<?php echo $editedImage[0] . '?' . time(); ?>">
@@ -236,7 +238,7 @@ class ManualImageCropEditorWindow {
236
  </div>
237
  <script>
238
  jQuery(document).ready(function($) {
239
- mic_attachment_id = <?php echo $_GET['postId']; ?>;
240
  mic_edited_size = '<?php echo $editedSize; ?>';
241
  mic_preview_scale = <?php echo $previewRatio; ?>;
242
 
@@ -282,6 +284,5 @@ class ManualImageCropEditorWindow {
282
  });
283
  </script>
284
  <?php
285
- die;
286
  }
287
  }
36
 
37
  $imageSizes = get_intermediate_image_sizes();
38
 
39
+ $editedSize = in_array($_GET['size'], $imageSizes) ? $_GET['size'] : null;
40
 
41
+ $postId = filter_var($_GET['postId'], FILTER_SANITIZE_NUMBER_INT);
42
+
43
  $sizeLabels = apply_filters( 'image_size_names_choose', array(
44
  'thumbnail' => __('Thumbnail'),
45
  'medium' => __('Medium'),
76
  // Get user defined label for the size or just cleanup a bit
77
  $label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
78
  $label = $sizesSettings[$s]['label'] ? $sizesSettings[$s]['label'] : $label;
79
+ echo '<a href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&size=' . $s . '&postId=' . $postId . '&width=940" class="mic-icon-' . $s . ' rm-crop-size-tab nav-tab ' . ( ($s == $editedSize) ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
80
  }
81
  ?>
82
  </h2>
95
 
96
  $uploadsDir = wp_upload_dir();
97
 
98
+ $metaData = wp_get_attachment_metadata($postId);
99
 
100
+ $src_file_url = wp_get_attachment_image_src($postId, 'full');
101
  if (!$src_file_url) {
102
  echo json_encode (array('status' => 'error', 'message' => 'wrong attachement' ) );
103
  exit;
158
 
159
  ?>
160
  <div style="margin: auto; width: <?php echo $previewWidth; ?>px;">
161
+ <img style="width: <?php echo $previewWidth; ?>px; height: <?php echo $previewHeight; ?>px;" id="jcrop_target" src="<?php echo wp_get_attachment_url($postId); ?>">
162
  </div>
163
  </div>
164
  <div class="mic-right-col">
182
  <br />
183
  <div style="width: <?php echo $smallPreviewWidth; ?>px; height: <?php echo $smallPreviewHeight; ?>px; overflow: hidden; margin-left: 5px; float: right;">
184
  <img id="preview"
185
+ src="<?php echo wp_get_attachment_url($postId); ?>">
186
  </div>
187
  </div>
188
 
189
  <div class="mic-48-col">
190
  <?php _e('Previous image:','microp');
191
+ $editedImage = wp_get_attachment_image_src($postId, $editedSize);
192
  ?>
193
  <div style="width: <?php echo $smallPreviewWidth; ?>px; height: <?php echo $smallPreviewHeight; ?>px; overflow: hidden; margin-left: 5px;">
194
  <img id="micPreviousImage" style="max-width: <?php echo $smallPreviewWidth; ?>px; max-height: <?php echo $smallPreviewHeight; ?>px;" src="<?php echo $editedImage[0] . '?' . time(); ?>">
238
  </div>
239
  <script>
240
  jQuery(document).ready(function($) {
241
+ mic_attachment_id = <?php echo $postId; ?>;
242
  mic_edited_size = '<?php echo $editedSize; ?>';
243
  mic_preview_scale = <?php echo $previewRatio; ?>;
244
 
284
  });
285
  </script>
286
  <?php
 
287
  }
288
  }
lib/ManualImageCropSettingsPage.php CHANGED
@@ -148,7 +148,10 @@ class MicSettingsPage
148
  </thead>
149
  <tbody>';
150
 
151
- $sizesSettings = self::getSettings() || array();
 
 
 
152
 
153
  foreach ($imageSizes as $s) {
154
  $label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
148
  </thead>
149
  <tbody>';
150
 
151
+ $sizesSettings = self::getSettings();
152
+ if (!is_array($sizesSettings)) {
153
+ $sizesSettings = array();
154
+ }
155
 
156
  foreach ($imageSizes as $s) {
157
  $label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
manual-image-crop.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
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.10
7
  Author: Tomasz Sita
8
  Author URI: https://github.com/tomaszsita
9
  License: GPL2
@@ -11,7 +11,7 @@ Text Domain: microp
11
  Domain Path: /languages/
12
  */
13
 
14
- define('mic_VERSION', '1.10');
15
 
16
  include_once(dirname(__FILE__) . '/lib/ManualImageCropSettingsPage.php');
17
 
1
  <?php
2
  /*
3
  Plugin Name: Manual Image Crop
4
+ Plugin URI: https://github.com/tomaszsita/wp-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.11
7
  Author: Tomasz Sita
8
  Author URI: https://github.com/tomaszsita
9
  License: GPL2
11
  Domain Path: /languages/
12
  */
13
 
14
+ define('mic_VERSION', '1.11');
15
 
16
  include_once(dirname(__FILE__) . '/lib/ManualImageCropSettingsPage.php');
17
 
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === Manual Image Crop ===
2
  Contributors: tomasz.sita
3
  Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
4
- Tested up to: 4.2.2
5
  Requires at least: 3.5
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WB5ZQWGUM7T96
9
- Stable tag: 1.10
10
 
11
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
12
 
@@ -28,10 +28,12 @@ Translations:
28
  * Dutch (Bernardo Hulsman)
29
  * French (Gabriel Féron)
30
  * German (Bertram Greenhough)
 
31
  * Italian (Alessandro Curci)
32
  * Polish (myself)
33
  * Russian (Andrey Hohlov)
34
  * Spanish (Andrew Kurtis)
 
35
 
36
  Please contact me if you want to add a translation (or submit a pull request on GitHub)
37
 
@@ -47,6 +49,11 @@ Automatically:
47
  * When the plugin has been installed, Click 'Activate'
48
 
49
  == Changelog ==
 
 
 
 
 
50
  = 1.10 =
51
  * Fixed handling of array $crop param
52
 
1
  === Manual Image Crop ===
2
  Contributors: tomasz.sita
3
  Tags: crop, cropping, thumbnail, featured image, gallery, images, picture, image, image area
4
+ Tested up to: 4.3
5
  Requires at least: 3.5
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WB5ZQWGUM7T96
9
+ Stable tag: 1.11
10
 
11
  Plugin allows you to manually crop all the image sizes registered in your WordPress theme (in particular featured image).
12
 
28
  * Dutch (Bernardo Hulsman)
29
  * French (Gabriel Féron)
30
  * German (Bertram Greenhough)
31
+ * Hungarian (Roland Kal)
32
  * Italian (Alessandro Curci)
33
  * Polish (myself)
34
  * Russian (Andrey Hohlov)
35
  * Spanish (Andrew Kurtis)
36
+ * Swedish (Karl Oskar Mattsson)
37
 
38
  Please contact me if you want to add a translation (or submit a pull request on GitHub)
39
 
49
  * When the plugin has been installed, Click 'Activate'
50
 
51
  == Changelog ==
52
+ = 1.11 =
53
+ * Hungarian translation added
54
+ * Swedish translation added
55
+ * Security improvements
56
+
57
  = 1.10 =
58
  * Fixed handling of array $crop param
59