Advanced Custom Fields: Image Crop Add-on - Version 1.4

Version Description

  • Fixed images with dot in the file name resulting in odd cropped image names
  • Fixed issues with php notices in v4
  • Fixed issues with broken image fields in v4
  • Temporarily fixed images smaller than preview size not being added (ACF bug)
  • Updated localization thanks to @tmconnect
  • Various tweaks and fixes by @tmconnect
Download this release

Release Info

Developer andersthorborg
Plugin Icon wp plugin Advanced Custom Fields: Image Crop Add-on
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

acf-image-crop-v4.php CHANGED
@@ -361,8 +361,8 @@ class acf_field_image_crop extends acf_field_image
361
  $height = $height * 2;
362
  }
363
  ?>
364
- <div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-field-id="<?php echo $field['key'] ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" data-width="<?php echo $width ?>" data-height="<?php echo $height ?>" data-crop-type="<?php echo $field['crop_type'] ?>" <?php echo ($field['force_crop'] == 'yes' ? 'data-force-crop="true"' : '')?> data-save-to-media-library="<?php echo $field['save_in_media_library'] ?>" >
365
- <input class="acf-image-value" data-original-image="<?php echo $data->original_image ?>" data-cropped-image="<?php echo json_encode($data->cropped_image) ?>" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo htmlspecialchars($field['value']); ?>" />
366
  <div class="has-image">
367
  <div class="image-section">
368
  <div class="hover">
@@ -764,11 +764,11 @@ class acf_field_image_crop extends acf_field_image
764
  // Crop the image using the provided measurements
765
  $image->crop($x1, $y1, $x2 - $x1, $y2 - $y1, $targetW, $targetH);
766
 
767
- // Retrieve original filename and seperate it from its file extension
768
- $originalFileName = explode('.', basename($originalImageData['file']));
769
 
770
  // Generate new base filename
771
- $targetFileName = $originalFileName[0] . '_' . $targetW . 'x' . $targetH . '_acf_cropped' . '.' . $originalFileName[1];
772
 
773
  // Generate target path new file using existing media library
774
  $targetFilePath = $mediaDir['path'] . '/' . wp_unique_filename( $mediaDir['path'], $targetFileName);
361
  $height = $height * 2;
362
  }
363
  ?>
364
+ <div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-field-id="<?php echo $field['key'] ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo isset($field['library']) ? $field['library'] : 'all'; ?>" data-width="<?php echo $width ?>" data-height="<?php echo $height ?>" data-crop-type="<?php echo $field['crop_type'] ?>" <?php echo ($field['force_crop'] == 'yes' ? 'data-force-crop="true"' : '')?> data-save-to-media-library="<?php echo $field['save_in_media_library'] ?>" >
365
+ <input class="acf-image-value" data-original-image="<?php echo $imageData->original_image ?>" data-cropped-image="<?php echo json_encode($imageData->cropped_image) ?>" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo htmlspecialchars($field['value']); ?>" />
366
  <div class="has-image">
367
  <div class="image-section">
368
  <div class="hover">
764
  // Crop the image using the provided measurements
765
  $image->crop($x1, $y1, $x2 - $x1, $y2 - $y1, $targetW, $targetH);
766
 
767
+ // Retrieve and remove file extension from array
768
+ $originalFileExtension = array_pop($originalFileName);
769
 
770
  // Generate new base filename
771
+ $targetFileName = implode('.', $originalFileName) . '_' . $targetW . 'x' . $targetH . '_acf_cropped' . '.' . $originalFileExtension;
772
 
773
  // Generate target path new file using existing media library
774
  $targetFilePath = $mediaDir['path'] . '/' . wp_unique_filename( $mediaDir['path'], $targetFileName);
acf-image-crop-v5.php CHANGED
@@ -73,7 +73,11 @@ class acf_field_image_crop extends acf_field_image {
73
  */
74
 
75
  $this->l10n = array(
76
- 'error' => __('Error! Please enter a higher value', 'acf-image_crop'),
 
 
 
 
77
  );
78
 
79
 
@@ -140,10 +144,16 @@ class acf_field_image_crop extends acf_field_image {
140
 
141
  // target_size
142
  $sizes = acf_get_image_sizes();
 
 
 
 
 
 
143
  $sizes['custom'] = __('Custom size', 'acf-image_crop');
144
  acf_render_field_setting( $field, array(
145
  'label' => __('Target size','acf-image_crop'),
146
- 'instructions' => __('Select the target size for this field' . ($this->getOption('retina_mode') ? '<br><br><em><b>Retina mode is enabled - user will be required to select an image twice this size</b></em>' : ''),'acf-image_crop'),
147
  'type' => 'select',
148
  'name' => 'target_size',
149
  'class' => 'target-size-select',
@@ -156,7 +166,8 @@ class acf_field_image_crop extends acf_field_image {
156
  'instructions' => __('Leave blank for no restriction (does not work with hard crop option)','acf-image_crop'),
157
  'type' => 'number',
158
  'name' => 'width',
159
- 'class' => 'custom-target-width custom-target-dimension'
 
160
  ));
161
 
162
  // height - conditional: target_size == 'custom'
@@ -165,13 +176,14 @@ class acf_field_image_crop extends acf_field_image {
165
  'instructions' => __('Leave blank for no restriction (does not work with hard crop option)','acf-image_crop'),
166
  'type' => 'number',
167
  'name' => 'height',
168
- 'class' => 'custom-target-height custom-target-dimension'
 
169
  ));
170
 
171
  // preview_size
172
  acf_render_field_setting( $field, array(
173
- 'label' => __('Preview size','acf-image_crop'),
174
- 'instructions' => __('Select the preview size for this field','acf-image_crop'),
175
  'type' => 'select',
176
  'name' => 'preview_size',
177
  'choices' => acf_get_image_sizes()
@@ -184,7 +196,7 @@ class acf_field_image_crop extends acf_field_image {
184
  'type' => 'radio',
185
  'layout' => 'horizontal',
186
  'name' => 'force_crop',
187
- 'choices' => array('yes' => 'Yes', 'no' => 'No')
188
  ));
189
 
190
  // save_in_media_library
@@ -195,36 +207,33 @@ class acf_field_image_crop extends acf_field_image {
195
  'layout' => 'horizontal',
196
  'name' => 'save_in_media_library',
197
  'class' => 'save-in-media-library-select',
198
- 'choices' => array('yes' => 'Yes', 'no' => 'No')
199
  ));
200
 
201
- // retina mode
202
- $retina_instructions = __('Require and crop double the size set for this image. Enable this if you are using plugins like WP Retina 2x.','acf-image_crop');
203
- if($this->getOption('retina_mode')){
204
- $retina_instructions .= '<br>' . __('NB. You currently have enabled retina mode globally for all fields through <a href="' . admin_url('options-media.php') . '#acf-image-crop-retina-mode' . '">settings</a>, which will override this setting.','acf-image_crop');
 
 
 
 
 
 
 
205
  }
206
- acf_render_field_setting( $field, array(
207
- 'label' => __('Retina/@2x mode ','acf-image_crop'),
208
- 'instructions' => $retina_instructions,
209
- 'type' => 'radio',
210
- 'layout' => 'horizontal',
211
- 'name' => 'retina_mode',
212
- 'choices' => array('yes' => 'Yes', 'no' => 'No')
213
- ));
214
-
215
-
216
  // return_format
217
  acf_render_field_setting( $field, array(
218
- 'label' => __('Return Value','acf-image_crop'),
219
- 'instructions' => __('Specify the returned value on front end','acf-image_crop'),
220
  'type' => 'radio',
221
  'name' => 'save_format',
222
  'layout' => 'horizontal',
223
  'class' => 'return-value-select',
224
  'choices' => array(
 
225
  'url' => __("Image URL",'acf'),
226
- 'id' => __("Image ID",'acf'),
227
- 'object' => __("Image Object",'acf')
228
  )
229
  ));
230
 
@@ -346,20 +355,20 @@ class acf_field_image_crop extends acf_field_image {
346
  <div class="crop-section">
347
  <div class="crop-stage">
348
  <div class="crop-action">
349
- <h4>Crop the image</h4>
350
  <?php if ($imageData->original_image ): ?>
351
  <img class="crop-image" src="<?php echo $imageData->original_image_url ?>" data-width="<?php echo $imageData->original_image_width ?>" data-height="<?php echo $imageData->original_image_height ?>" alt="">
352
  <?php endif ?>
353
  </div>
354
  <div class="crop-preview">
355
- <h4>Preview</h4>
356
  <div class="preview"></div>
357
  <div class="crop-controls">
358
- <a href="#" class="button button-large cancel-crop-button">Cancel</a> <a href="#" class="button button-large button-primary perform-crop-button">Crop!</a>
359
  </div>
360
  </div>
361
  </div>
362
- <a href="#" class="button button-large init-crop-button">Crop</a>
363
  </div>
364
  </div>
365
  <div class="view hide-if-value">
@@ -524,8 +533,11 @@ class acf_field_image_crop extends acf_field_image {
524
  // Retrieve original filename and seperate it from its file extension
525
  $originalFileName = explode('.', basename($originalImageData['file']));
526
 
 
 
 
527
  // Generate new base filename
528
- $targetFileName = $originalFileName[0] . '_' . $targetW . 'x' . $targetH . '_acf_cropped' . '.' . $originalFileName[1];
529
 
530
  // Generate target path new file using existing media library
531
  $targetFilePath = $mediaDir['path'] . '/' . wp_unique_filename( $mediaDir['path'], $targetFileName);
@@ -650,7 +662,13 @@ class acf_field_image_crop extends acf_field_image {
650
 
651
  register_setting(
652
  'media', // settings page
653
- 'acf_image_crop_settings' // option name
 
 
 
 
 
 
654
  );
655
 
656
  add_settings_field(
@@ -698,7 +716,15 @@ class acf_field_image_crop extends acf_field_image {
698
  echo '';
699
  }
700
 
 
 
 
 
 
701
 
 
 
 
702
 
703
 
704
 
73
  */
74
 
75
  $this->l10n = array(
76
+ 'width_should_be' => __( 'Width should be at least: ','acf-image_crop' ),
77
+ 'height_should_be' => __( 'Height should be at least: ','acf-image_crop' ),
78
+ 'selected_width' => __( 'Selected image width: ','acf-image_crop' ),
79
+ 'selected_height' => __( 'Selected image height: ','acf-image_crop' ),
80
+ 'size_warning' => __( 'Warning: The selected image is smaller than the required size!','acf-image_crop' )
81
  );
82
 
83
 
144
 
145
  // target_size
146
  $sizes = acf_get_image_sizes();
147
+ // added
148
+ $instructions = __('Select the target size for this field','acf-image_crop');
149
+ if ( $this->getOption('retina_mode') ) {
150
+ $instructions .= '<br><br><em><strong>'.__('Retina mode is enabled - user will be required to select an image twice this size','acf-image_crop').'</strong></em>';
151
+ }
152
+ // added END
153
  $sizes['custom'] = __('Custom size', 'acf-image_crop');
154
  acf_render_field_setting( $field, array(
155
  'label' => __('Target size','acf-image_crop'),
156
+ 'instructions' => $instructions,
157
  'type' => 'select',
158
  'name' => 'target_size',
159
  'class' => 'target-size-select',
166
  'instructions' => __('Leave blank for no restriction (does not work with hard crop option)','acf-image_crop'),
167
  'type' => 'number',
168
  'name' => 'width',
169
+ 'class' => 'custom-target-width custom-target-dimension',
170
+ 'append' => 'px'
171
  ));
172
 
173
  // height - conditional: target_size == 'custom'
176
  'instructions' => __('Leave blank for no restriction (does not work with hard crop option)','acf-image_crop'),
177
  'type' => 'number',
178
  'name' => 'height',
179
+ 'class' => 'custom-target-height custom-target-dimension',
180
+ 'append' => 'px'
181
  ));
182
 
183
  // preview_size
184
  acf_render_field_setting( $field, array(
185
+ 'label' => __('Preview Size','acf'),
186
+ 'instructions' => __('Shown when entering data','acf'),
187
  'type' => 'select',
188
  'name' => 'preview_size',
189
  'choices' => acf_get_image_sizes()
196
  'type' => 'radio',
197
  'layout' => 'horizontal',
198
  'name' => 'force_crop',
199
+ 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))
200
  ));
201
 
202
  // save_in_media_library
207
  'layout' => 'horizontal',
208
  'name' => 'save_in_media_library',
209
  'class' => 'save-in-media-library-select',
210
+ 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))
211
  ));
212
 
213
+ // only show this setting if the global option for retina mode is not activated
214
+ // retina mode
215
+ if ( !$this->getOption('retina_mode') ) {
216
+ acf_render_field_setting( $field, array(
217
+ 'label' => __('Retina/@2x mode ','acf-image_crop'),
218
+ 'instructions' => __('Require and crop double the size set for this image. Enable this if you are using plugins like WP Retina 2x.','acf-image_crop'),
219
+ 'type' => 'radio',
220
+ 'layout' => 'horizontal',
221
+ 'name' => 'retina_mode',
222
+ 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))
223
+ ));
224
  }
 
 
 
 
 
 
 
 
 
 
225
  // return_format
226
  acf_render_field_setting( $field, array(
227
+ 'label' => __('Return Value','acf'),
228
+ 'instructions' => __('Specify the returned value on front end','acf'),
229
  'type' => 'radio',
230
  'name' => 'save_format',
231
  'layout' => 'horizontal',
232
  'class' => 'return-value-select',
233
  'choices' => array(
234
+ 'object' => __("Image Array",'acf'),
235
  'url' => __("Image URL",'acf'),
236
+ 'id' => __("Image ID",'acf')
 
237
  )
238
  ));
239
 
355
  <div class="crop-section">
356
  <div class="crop-stage">
357
  <div class="crop-action">
358
+ <h4><?php _e('Crop the image','acf-image_crop'); ?></h4>
359
  <?php if ($imageData->original_image ): ?>
360
  <img class="crop-image" src="<?php echo $imageData->original_image_url ?>" data-width="<?php echo $imageData->original_image_width ?>" data-height="<?php echo $imageData->original_image_height ?>" alt="">
361
  <?php endif ?>
362
  </div>
363
  <div class="crop-preview">
364
+ <h4><?php _e('Preview','acf-image_crop'); ?></h4>
365
  <div class="preview"></div>
366
  <div class="crop-controls">
367
+ <a href="#" class="button button-large cancel-crop-button"><?php _e('Cancel','acf-image_crop'); ?></a> <a href="#" class="button button-large button-primary perform-crop-button"><?php _e('Crop!','acf-image_crop'); ?></a>
368
  </div>
369
  </div>
370
  </div>
371
+ <a href="#" class="button button-large init-crop-button"><?php _e('Crop','acf-image_crop'); ?></a>
372
  </div>
373
  </div>
374
  <div class="view hide-if-value">
533
  // Retrieve original filename and seperate it from its file extension
534
  $originalFileName = explode('.', basename($originalImageData['file']));
535
 
536
+ // Retrieve and remove file extension from array
537
+ $originalFileExtension = array_pop($originalFileName);
538
+
539
  // Generate new base filename
540
+ $targetFileName = implode('.', $originalFileName) . '_' . $targetW . 'x' . $targetH . '_acf_cropped' . '.' . $originalFileExtension;
541
 
542
  // Generate target path new file using existing media library
543
  $targetFilePath = $mediaDir['path'] . '/' . wp_unique_filename( $mediaDir['path'], $targetFileName);
662
 
663
  register_setting(
664
  'media', // settings page
665
+ 'acf_image_crop_settings', // option name
666
+ // added
667
+ // a callback to a new function to set options to false and not to an empty string
668
+ // there was an error if you set an option, save and then unset this option and save again
669
+ // because the option value could be empty if non of the options is activated
670
+ array($this, 'validateImageCropSettingsSection')
671
+ // added END
672
  );
673
 
674
  add_settings_field(
716
  echo '';
717
  }
718
 
719
+ // added
720
+ // a function that sets theoptions value to false
721
+ function validateImageCropSettingsSection($input) {
722
+ $input['hide_cropped'] = ( $input['hide_cropped'] == true ? true : false );
723
+ $input['retina_mode'] = ( $input['retina_mode'] == true ? true : false );
724
 
725
+ return $input;
726
+ }
727
+ // added END
728
 
729
 
730
 
acf-image-crop.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields: Image Crop Add-on
4
  Plugin URI: https://github.com/andersthorborg/ACF-Image-Crop
5
  Description: An image field making it possible/required for the user to crop the selected image to the specified image size or dimensions
6
- Version: 1.3
7
  Author: Anders Thorborg
8
  Author URI: http://thorb.org
9
  License: GPLv2 or later
@@ -21,7 +21,7 @@ load_plugin_textdomain( 'acf-image_crop', false, dirname( plugin_basename(__FILE
21
  // 2. Include field type for ACF5
22
  // $version = 5 and can be ignored until ACF6 exists
23
  function include_field_types_image_crop( $version ) {
24
- include_once('acf-image-crop-v5.php');
25
 
26
  }
27
 
@@ -33,7 +33,7 @@ add_action('acf/include_field_types', 'include_field_types_image_crop');
33
  // 3. Include field type for ACF4
34
  function register_fields_image_crop() {
35
 
36
- include_once('acf-image-crop-v4.php');
37
 
38
  }
39
 
@@ -43,7 +43,9 @@ add_action('acf/register_fields', 'register_fields_image_crop');
43
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'acf_image_crop_action_links' );
44
 
45
  function acf_image_crop_action_links( $links ) {
46
- $links[] = '<a href="'. get_admin_url(null, 'options-media.php') .'">Settings</a>';
 
 
47
  return $links;
48
  }
49
 
3
  Plugin Name: Advanced Custom Fields: Image Crop Add-on
4
  Plugin URI: https://github.com/andersthorborg/ACF-Image-Crop
5
  Description: An image field making it possible/required for the user to crop the selected image to the specified image size or dimensions
6
+ Version: 1.4
7
  Author: Anders Thorborg
8
  Author URI: http://thorb.org
9
  License: GPLv2 or later
21
  // 2. Include field type for ACF5
22
  // $version = 5 and can be ignored until ACF6 exists
23
  function include_field_types_image_crop( $version ) {
24
+ include_once('acf-image-crop-v5.php');
25
 
26
  }
27
 
33
  // 3. Include field type for ACF4
34
  function register_fields_image_crop() {
35
 
36
+ include_once('acf-image-crop-v4.php');
37
 
38
  }
39
 
43
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'acf_image_crop_action_links' );
44
 
45
  function acf_image_crop_action_links( $links ) {
46
+ // changed
47
+ $links[] = '<a href="'. get_admin_url(null, 'options-media.php') .'">'.__('Settings','acf-image_crop').'</a>';
48
+ // changed END
49
  return $links;
50
  }
51
 
css/input.css CHANGED
@@ -7,8 +7,16 @@
7
  }
8
  .field_type-image_crop .crop-stage .crop-preview{
9
  float:right;
10
- width:25%;
 
 
11
  }
 
 
 
 
 
 
12
  .field_type-image_crop .crop-stage .crop-preview .preview{
13
  width:100%;
14
  }
@@ -16,6 +24,9 @@
16
  .field_type-image_crop .crop-stage .crop-preview .crop-controls{
17
  padding-top:20px;
18
  clear: both;
 
 
 
19
  }
20
 
21
  .field_type-image_crop .crop-section .crop-stage, .field_type-image_crop.cropping .image-section, .field_type-image_crop.cropping .init-crop-button{
@@ -25,14 +36,18 @@
25
  display:block;
26
  position:fixed;
27
  top:60px;
28
- width:800px;
 
 
29
  left:50%;
30
  margin-left:-440px;
31
  height:auto;
32
  background-color: #fff;
33
  box-shadow: 0px 0px 3px rgba(0,0,0,0.5);
34
- padding:40px;
35
- z-index: 100;
 
 
36
 
37
  }
38
  .field_type-image_crop.cropping .has-image, .field_type-image_crop.cropping .crop-section{
@@ -53,8 +68,16 @@
53
  .button.init-crop-button{
54
  margin-top: 20px;
55
  }
 
 
 
 
 
56
  #acf-image-crop-overlay{
57
  position:fixed;
 
 
 
58
  top:0px;
59
  left:0px;
60
  right:0px;
7
  }
8
  .field_type-image_crop .crop-stage .crop-preview{
9
  float:right;
10
+ /* changed */
11
+ width: 30%;
12
+ /* changed END */
13
  }
14
+ /* added */
15
+ .field_type-image_crop .crop-stage .crop-action h4,
16
+ .field_type-image_crop .crop-stage .crop-preview h4{
17
+ margin-top:0;
18
+ }
19
+ /* added END */
20
  .field_type-image_crop .crop-stage .crop-preview .preview{
21
  width:100%;
22
  }
24
  .field_type-image_crop .crop-stage .crop-preview .crop-controls{
25
  padding-top:20px;
26
  clear: both;
27
+ /* added */
28
+ text-align: right;
29
+ /* added END */
30
  }
31
 
32
  .field_type-image_crop .crop-section .crop-stage, .field_type-image_crop.cropping .image-section, .field_type-image_crop.cropping .init-crop-button{
36
  display:block;
37
  position:fixed;
38
  top:60px;
39
+ /* changed */
40
+ width:880px;
41
+ /* changed END */
42
  left:50%;
43
  margin-left:-440px;
44
  height:auto;
45
  background-color: #fff;
46
  box-shadow: 0px 0px 3px rgba(0,0,0,0.5);
47
+ padding: 25px;
48
+ /* changed */
49
+ z-index: 11000;
50
+ /* changed END */
51
 
52
  }
53
  .field_type-image_crop.cropping .has-image, .field_type-image_crop.cropping .crop-section{
68
  .button.init-crop-button{
69
  margin-top: 20px;
70
  }
71
+ /* added */
72
+ .button.button-large.button-primary.perform-crop-button {
73
+ margin-left:15px;
74
+ }
75
+ /* added END */
76
  #acf-image-crop-overlay{
77
  position:fixed;
78
+ /* added */
79
+ z-index: 10000;
80
+ /* added END */
81
  top:0px;
82
  left:0px;
83
  right:0px;
js/input.js CHANGED
@@ -122,7 +122,11 @@
122
  attachment.url = attachment.attributes.sizes[ this.settings.preview_size ].url;
123
 
124
  }
 
 
125
 
 
 
126
 
127
  // set atts
128
  this.$el.find('[data-name="image"]').attr( 'src', attachment.url );
@@ -203,17 +207,23 @@ function initialize_field( $el ) {
203
  var warnings = [];
204
  var valid = true;
205
  if($options.data('width') && data['width'] < $options.data('width')){
206
- warnings.push('Width should be at least: ' + $options.data('width') + 'px (Selected image width: ' + data['width'] + 'px)');
 
 
207
  valid = false;
208
  }
209
  if($options.data('height') && data['height'] < $options.data('height')){
210
- warnings.push('Height should be at least: ' + $options.data('height') + 'px (Selected image height: ' + data['height'] + 'px)');
 
 
211
  valid = false;
212
  }
213
  if(!valid){
214
  $field.addClass('invalid');
215
  $field.find('.init-crop-button').attr('disabled', 'disabled');
216
- alert('Warning: The selected image is smaller than the required size:\n' + warnings.join('\n'));
 
 
217
  }
218
  else{
219
  if($options.data('force_crop')){
122
  attachment.url = attachment.attributes.sizes[ this.settings.preview_size ].url;
123
 
124
  }
125
+ // set url to default url in case preview size does not exist
126
+ else if(acf.isset(attachment, 'attributes', 'url')){
127
 
128
+ attachment.url = attachment.attributes.url;
129
+ }
130
 
131
  // set atts
132
  this.$el.find('[data-name="image"]').attr( 'src', attachment.url );
207
  var warnings = [];
208
  var valid = true;
209
  if($options.data('width') && data['width'] < $options.data('width')){
210
+ // changed for translation
211
+ warnings.push( acf._e('image_crop', 'width_should_be') + $options.data('width') + 'px\n' + acf._e('image_crop', 'selected_width') + data['width'] + 'px');
212
+ // changed END
213
  valid = false;
214
  }
215
  if($options.data('height') && data['height'] < $options.data('height')){
216
+ // changed for translation
217
+ warnings.push(acf._e('image_crop', 'height_should_be') + $options.data('height') + 'px\n' + acf._e('image_crop', 'selected_height') + data['height'] + 'px');
218
+ // changed END
219
  valid = false;
220
  }
221
  if(!valid){
222
  $field.addClass('invalid');
223
  $field.find('.init-crop-button').attr('disabled', 'disabled');
224
+ // changed for translation
225
+ alert(acf._e('image_crop', 'size_warning') + '\n\n' + warnings.join('\n\n'));
226
+ // changed END
227
  }
228
  else{
229
  if($options.data('force_crop')){
lang/acf-image_crop-de_DE.mo ADDED
Binary file
lang/acf-image_crop-de_DE.po ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Custom Fields: Image Crop Add-on v1.3\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2014-09-13 13:45:02+0000\n"
7
+ "Last-Translator: thomas <t.meyer@me.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: German\n"
15
+ "X-Poedit-Country: GERMANY\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: \n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: acf-image-crop-v4.php:23
24
+ #: acf-image-crop-v5.php:32
25
+ #@ default
26
+ #@ acf-image_crop
27
+ msgid "Image with user-crop"
28
+ msgstr "Bild (mit Größenoption)"
29
+
30
+ #: acf-image-crop-v4.php:24
31
+ #@ acf
32
+ msgid "Content"
33
+ msgstr ""
34
+
35
+ #: acf-image-crop-v4.php:105
36
+ #: acf-image-crop-v5.php:133
37
+ #@ acf
38
+ #@ acf-image_crop
39
+ msgid "Crop type"
40
+ msgstr "Art Beschnitt"
41
+
42
+ #: acf-image-crop-v4.php:106
43
+ #: acf-image-crop-v5.php:134
44
+ #@ acf
45
+ #@ acf-image_crop
46
+ msgid "Select the type of crop the user should perform"
47
+ msgstr "Auswahl, wie der Beschnitt angewendet wird"
48
+
49
+ #: acf-image-crop-v4.php:117
50
+ #: acf-image-crop-v5.php:140
51
+ #@ acf
52
+ #@ acf-image_crop
53
+ msgid "Hard crop"
54
+ msgstr "Absoluter Beschnitt"
55
+
56
+ #: acf-image-crop-v4.php:118
57
+ #: acf-image-crop-v5.php:141
58
+ #@ acf
59
+ #@ acf-image_crop
60
+ msgid "Minimal dimensions"
61
+ msgstr "Mindestgröße"
62
+
63
+ #: acf-image-crop-v4.php:127
64
+ #@ acf
65
+ msgid "Target Size"
66
+ msgstr ""
67
+
68
+ #: acf-image-crop-v4.php:128
69
+ #: acf-image-crop-v4.php:176
70
+ #: acf-image-crop-v5.php:147
71
+ #@ acf
72
+ #@ acf-image_crop
73
+ msgid "Select the target size for this field"
74
+ msgstr "Definiert die Zielgröße des beschnittenen Bildes"
75
+
76
+ #: acf-image-crop-v4.php:132
77
+ #: acf-image-crop-v5.php:151
78
+ #@ acf
79
+ #@ acf-image_crop
80
+ msgid "Custom size"
81
+ msgstr "Benutzerdefiniert"
82
+
83
+ #: acf-image-crop-v4.php:147
84
+ #@ acf
85
+ msgid "Dimensions"
86
+ msgstr ""
87
+
88
+ #: acf-image-crop-v4.php:148
89
+ #@ acf
90
+ msgid "Enter the dimensions for the image."
91
+ msgstr ""
92
+
93
+ #: acf-image-crop-v4.php:148
94
+ #@ acf
95
+ msgid "Enter the minimum dimensions for the image. Leave fields blank for no minimum requirement."
96
+ msgstr ""
97
+
98
+ #: acf-image-crop-v4.php:175
99
+ #: acf-image-crop-v5.php:183
100
+ #: image_crop-v3.php:130
101
+ #@ acf
102
+ msgid "Preview Size"
103
+ msgstr ""
104
+
105
+ #: acf-image-crop-v4.php:193
106
+ #: acf-image-crop-v5.php:192
107
+ #@ acf
108
+ #@ acf-image_crop
109
+ msgid "Force crop"
110
+ msgstr "Beschnitt starten"
111
+
112
+ #: acf-image-crop-v4.php:194
113
+ #@ acf
114
+ msgid "Force the user to crop the image as soon at it is selected."
115
+ msgstr ""
116
+
117
+ #: acf-image-crop-v4.php:204
118
+ #: acf-image-crop-v4.php:224
119
+ #: acf-image-crop-v4.php:251
120
+ #: acf-image-crop-v5.php:197
121
+ #: acf-image-crop-v5.php:208
122
+ #: acf-image-crop-v5.php:219
123
+ #@ acf
124
+ msgid "Yes"
125
+ msgstr ""
126
+
127
+ #: acf-image-crop-v4.php:205
128
+ #: acf-image-crop-v4.php:225
129
+ #: acf-image-crop-v4.php:252
130
+ #: acf-image-crop-v5.php:197
131
+ #: acf-image-crop-v5.php:208
132
+ #: acf-image-crop-v5.php:219
133
+ #@ acf
134
+ msgid "No"
135
+ msgstr ""
136
+
137
+ #: acf-image-crop-v4.php:213
138
+ #@ acf
139
+ msgid "Save cropped image in media library"
140
+ msgstr ""
141
+
142
+ #: acf-image-crop-v4.php:214
143
+ #@ acf
144
+ msgid "If the cropped image is not saved in the media library, the \"Image URL\" is the only available return value."
145
+ msgstr ""
146
+
147
+ #: acf-image-crop-v4.php:260
148
+ #: acf-image-crop-v5.php:225
149
+ #@ acf
150
+ msgid "Return Value"
151
+ msgstr "Rückgabewert"
152
+
153
+ #: acf-image-crop-v4.php:261
154
+ #: acf-image-crop-v5.php:226
155
+ #@ acf
156
+ msgid "Specify the returned value on front end"
157
+ msgstr "Legt den Rückgabewert im Front-End fest"
158
+
159
+ #: acf-image-crop-v4.php:271
160
+ #: acf-image-crop-v5.php:233
161
+ #@ acf
162
+ msgid "Image URL"
163
+ msgstr ""
164
+
165
+ #: acf-image-crop-v4.php:272
166
+ #: acf-image-crop-v5.php:234
167
+ #@ acf
168
+ msgid "Image ID"
169
+ msgstr ""
170
+
171
+ #: acf-image-crop-v4.php:273
172
+ #@ acf
173
+ msgid "Image Object"
174
+ msgstr ""
175
+
176
+ #: acf-image-crop-v4.php:370
177
+ #@ acf
178
+ msgid "Remove"
179
+ msgstr ""
180
+
181
+ #: acf-image-crop-v4.php:371
182
+ #@ acf
183
+ msgid "Edit"
184
+ msgstr ""
185
+
186
+ #: acf-image-crop-v4.php:397
187
+ #: acf-image-crop-v5.php:381
188
+ #@ acf
189
+ msgid "No image selected"
190
+ msgstr ""
191
+
192
+ #: acf-image-crop-v4.php:397
193
+ #: acf-image-crop-v5.php:381
194
+ #@ acf
195
+ msgid "Add Image"
196
+ msgstr ""
197
+
198
+ #: acf-image-crop-v5.php:153
199
+ #@ acf-image_crop
200
+ msgid "Target size"
201
+ msgstr "Zielgröße"
202
+
203
+ #: acf-image-crop-v5.php:163
204
+ #@ acf-image_crop
205
+ msgid "Custom target width"
206
+ msgstr "Benutzerdefinierte Breite"
207
+
208
+ #: acf-image-crop-v5.php:164
209
+ #: acf-image-crop-v5.php:174
210
+ #@ acf-image_crop
211
+ msgid "Leave blank for no restriction (does not work with hard crop option)"
212
+ msgstr "Leer lassen für keine Einschränkung (\"Absoluter Beschnitt\" erfordert eine Eingabe)"
213
+
214
+ #: acf-image-crop-v5.php:173
215
+ #@ acf-image_crop
216
+ msgid "Custom target height"
217
+ msgstr "Benutzerdefinierte Höhe"
218
+
219
+ #: acf-image-crop-v5.php:193
220
+ #@ acf-image_crop
221
+ msgid "Force the user to crop the image as soon at it is selected"
222
+ msgstr "Öffnet das Bearbeitungsfenster für den Beschnitt, sobald das Bild ausgewählt ist."
223
+
224
+ #: acf-image-crop-v5.php:202
225
+ #@ acf-image_crop
226
+ msgid "Save cropped image to media library"
227
+ msgstr "Speichere beschnittenes Bild in der Mediathek"
228
+
229
+ #: acf-image-crop-v5.php:203
230
+ #@ acf-image_crop
231
+ msgid "If the cropped image is not saved in the media library, \"Image URL\" is the only available return value."
232
+ msgstr "Wenn das beschnittene Bild nicht in der Mediathek gespeichert wird, steht nur \"Bild URL\" als Rückgabewert zur Verfügung"
233
+
234
+ #: acf-image-crop-v5.php:240
235
+ #@ acf
236
+ msgid "Library"
237
+ msgstr ""
238
+
239
+ #: acf-image-crop-v5.php:241
240
+ #@ acf
241
+ msgid "Limit the media library choice"
242
+ msgstr ""
243
+
244
+ #: acf-image-crop-v5.php:246
245
+ #@ acf
246
+ msgid "All"
247
+ msgstr ""
248
+
249
+ #: acf-image-crop-v5.php:247
250
+ #@ acf
251
+ msgid "Uploaded to post"
252
+ msgstr ""
253
+
254
+ #: acf-image-crop-v5.php:76
255
+ #@ acf-image_crop
256
+ msgid "Width should be at least: "
257
+ msgstr "Breite mindestens: "
258
+
259
+ #: acf-image-crop-v5.php:77
260
+ #@ acf-image_crop
261
+ msgid "Height should be at least: "
262
+ msgstr "Höhe mindestens: "
263
+
264
+ #: acf-image-crop-v5.php:78
265
+ #@ acf-image_crop
266
+ msgid "Selected image width: "
267
+ msgstr "Breite ausgewähltes Bild: "
268
+
269
+ #: acf-image-crop-v5.php:79
270
+ #@ acf-image_crop
271
+ msgid "Selected image height: "
272
+ msgstr "Höhe ausgewähltes Bild: "
273
+
274
+ #: acf-image-crop-v5.php:80
275
+ #@ acf-image_crop
276
+ msgid "Warning: The selected image is smaller than the required size!"
277
+ msgstr "Warnung: Das ausgewählte Bild ist kleiner als die geforderte Mindestgröße!"
278
+
279
+ #: image_crop-v3.php:30
280
+ #@ default
281
+ msgid "Image - Custom crop"
282
+ msgstr ""
283
+
284
+ #: image_crop-v3.php:131
285
+ #@ acf
286
+ msgid "Thumbnail is advised"
287
+ msgstr ""
288
+
289
+ #: image_crop-v3.php:142
290
+ #@ default
291
+ msgid "Thumbnail"
292
+ msgstr ""
293
+
294
+ #: image_crop-v3.php:143
295
+ #@ default
296
+ msgid "Something Else"
297
+ msgstr ""
298
+
299
+ #: acf-image-crop-v5.php:232
300
+ #@ acf
301
+ msgid "Image Array"
302
+ msgstr ""
303
+
304
+ #: acf-image-crop-v4.php:889
305
+ #: acf-image-crop-v5.php:661
306
+ #@ acf-image_crop
307
+ msgid "ACF Image Crop Settings"
308
+ msgstr "ACF Image Crop Einstellungen"
309
+
310
+ #: acf-image-crop-v4.php:901
311
+ #: acf-image-crop-v5.php:674
312
+ #@ acf-image_crop
313
+ msgid "Hide cropped images from media dialog"
314
+ msgstr "Beschnittene Bilder in Medienübersicht ausblenden"
315
+
316
+ #: acf-image-crop-v4.php:233
317
+ #: acf-image-crop-v5.php:215
318
+ #@ acf-image_crop
319
+ msgid "Require and crop double the size set for this image. Enable this if you are using plugins like WP Retina 2x."
320
+ msgstr "Retina Modus aktivieren - Der Anwender muss ein Bild in doppelter Größe auswählen. Diese Option sollte aktiviert werden, wenn ein Plugin wie z.B. WP Retina 2x aktiviert ist."
321
+
322
+ #: acf-image-crop-v4.php:240
323
+ #: acf-image-crop-v5.php:214
324
+ #@ acf-image_crop
325
+ msgid "Retina/@2x mode "
326
+ msgstr "Retina/@2x Modus"
327
+
328
+ #: acf-image-crop-v4.php:909
329
+ #: acf-image-crop-v5.php:682
330
+ #@ acf-image_crop
331
+ msgid "Enable global retina mode (beta)"
332
+ msgstr "Globalen Retina Modus (beta) aktivieren"
333
+
334
+ #: acf-image-crop-v5.php:149
335
+ #@ acf-image_crop
336
+ msgid "Retina mode is enabled - user will be required to select an image twice this size"
337
+ msgstr "Retina Modus ist aktiviert - Der Anwender muss ein Bild in doppelter Größe auswählen"
338
+
339
+ #: acf-image-crop-v5.php:184
340
+ #@ acf
341
+ msgid "Shown when entering data"
342
+ msgstr ""
343
+
344
+ #: acf-image-crop-v5.php:357
345
+ #@ acf-image_crop
346
+ msgid "Crop the image"
347
+ msgstr "Bildauschnitt wählen"
348
+
349
+ #: acf-image-crop-v5.php:365
350
+ #@ acf-image_crop
351
+ msgid "Preview"
352
+ msgstr "Vorschau"
353
+
354
+ #: acf-image-crop-v5.php:370
355
+ #@ acf-image_crop
356
+ msgid "Cancel"
357
+ msgstr "Abbrechen"
358
+
359
+ #: acf-image-crop-v5.php:370
360
+ #@ acf-image_crop
361
+ msgid "Crop!"
362
+ msgstr "Beschneiden"
363
+
364
+ #: acf-image-crop-v5.php:376
365
+ #@ acf-image_crop
366
+ msgid "Crop"
367
+ msgstr "Beschneiden"
368
+
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: andersthorborg
3
  Tags: afc, advanced custom fields, image crop, image, crop
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
- Stable tag: 1.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,6 +61,14 @@ function my_register_fields()
61
 
62
  == Changelog ==
63
 
 
 
 
 
 
 
 
 
64
  = 1.3 =
65
  * Updated to be compatible with original image field changes as of ACF Pro 5.0.8. IMPORTANT: As this is a quick fix to ensure compatability with the newest ACF PRO version it is not backwards compatible. If you are using ACF Pro 5.0.7 and below, please use version 1.2 of this add-on.
66
 
3
  Tags: afc, advanced custom fields, image crop, image, crop
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
+ Stable tag: 1.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.4 =
65
+ * Fixed images with dot in the file name resulting in odd cropped image names
66
+ * Fixed issues with php notices in v4
67
+ * Fixed issues with broken image fields in v4
68
+ * Temporarily fixed images smaller than preview size not being added (ACF bug)
69
+ * Updated localization thanks to @tmconnect
70
+ * Various tweaks and fixes by @tmconnect
71
+
72
  = 1.3 =
73
  * Updated to be compatible with original image field changes as of ACF Pro 5.0.8. IMPORTANT: As this is a quick fix to ensure compatability with the newest ACF PRO version it is not backwards compatible. If you are using ACF Pro 5.0.7 and below, please use version 1.2 of this add-on.
74