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

Version Description

  • Fix button styling
  • Prevent php warnings for unset field settings
Download this release

Release Info

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

Code changes from version 1.4.7 to 1.4.8

README.md DELETED
@@ -1,76 +0,0 @@
1
- -----------------------
2
-
3
- # ACF { Image Crop Add-on
4
-
5
- Adds an 'Image with user-crop' field type for the [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) WordPress plugin.
6
-
7
-
8
-
9
- -----------------------
10
-
11
- ### Overview
12
- ACF image crop is an extended version of the native Image-field in ACF.
13
- The field gives the developer/administrator the option to predefine a size for the image, which the user is prompted to crop on the various edit screens. This solves the common issue of images being cropped inappropriately by the automated center-crop, that wordpress performs.
14
-
15
- The plugin supports the defined image sizes as well as a custom option, enabling the developer to specify the dimensions from within the field edit screen.
16
-
17
- The field can be configured to enforce a hard crop or a minimal-dimension-based crop. The hard crop will lock the aspect ratio of the crop where as the minimal-dimension-based crop will not allow the user to crop the image below the specified dimensions.
18
-
19
- This plugin diverts from plugins like [Manual Image Crop](http://wordpress.org/plugins/manual-image-crop/) in that when the user crops an image, a new attachment is generated, so that the relevant crop only applies in the context it is edited. It also spares the user from dealing with the concept of various image sizes.
20
-
21
- As of version 1.0 the field can be configured to either create the cropped image as a media-item (the default behavior) or simply create it and refer directly to the file without adding it to the media library. This will prevent the media library from being cluttered with several cropped versions of the same image. When this option is selected the only available return type for the field is URL.
22
-
23
-
24
-
25
- ### Compatibility
26
-
27
- This add-on will work with:
28
-
29
- * version 4 and up
30
-
31
- ### Installation
32
-
33
- This add-on can be treated as both a WP plugin and a theme include.
34
-
35
- **Install as Plugin**
36
-
37
- 1. Copy the 'acf-image_crop' folder into your plugins folder
38
- 2. Activate the plugin via the Plugins admin page
39
-
40
- **Include within theme**
41
-
42
- 1. Copy the 'acf-image_crop' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
43
- 2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-image_crop.php file)
44
-
45
- ```php
46
- include_once('acf-image_crop/acf-image_crop.php');
47
- ```
48
-
49
- ### Setup
50
-
51
- The field has the same options as the standard image field. Besides from these, other options are available:
52
-
53
- **Crop type**
54
-
55
- Defines what kind of crop the user is going to perform. If the *Hard crop* option is selected, the aspect ratio of the selected size will be maintained.
56
-
57
- The *Minimal dimensions* option uses the specified size as minima requirements. With this option, the user will not be able to crop the image below the specified dimensions. If a dimension is not specified, the user will be able to crop that dimension to any value.
58
-
59
- **Target size**
60
-
61
- The size, that the image will ultimately be cropped into. This list includes the currently defined image sizes as well as the custom option. If the custom option is selected, a *dimension* opition will become available asking for width:height. NB. When using a custom target size along with the hard crop option **both width and height must be specified**.
62
-
63
- **Force crop**
64
-
65
- On the image field will be a *Crop*-button triggering the crop dialog. If the force crop option is enabled, the crop dialog will show up as soon as the user selects an image.
66
-
67
- **Retina/@2x mode**
68
-
69
- Makes the image field require double the dimensions selected. This makes it easier to integrate with plugins like WP Retina 2x.
70
-
71
- ###Further Details
72
- Whenever the user selects an image, the original image is stored, so whenever the user decides to re-crop the image the user will see the image first selected, and not the cropped one. Every crop made creates a seperate media item, which allows for multiple uses of the same image wihtout overwriting previous crops.
73
-
74
- The plugin settings can be found under Settings -> Media. Here you can enable global "Retina Mode" and choose to hide cropped images from the media dialog.
75
-
76
- The plugin has only been tested with Chrome for Mac, and still needs a lot of work. Please let me know of any issues or feature requests.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acf-image-crop-v4.php CHANGED
@@ -153,7 +153,7 @@ class acf_field_image_crop extends acf_field_image
153
  do_action('acf/create_field', array(
154
  'type' => 'text',
155
  'name' => 'fields[' . $key . '][width]',
156
- 'value' => $field['width'],
157
  'class' => 'width dimension',
158
  'placeholder' => 'Width'
159
  ));
@@ -163,7 +163,7 @@ class acf_field_image_crop extends acf_field_image
163
  do_action('acf/create_field', array(
164
  'type' => 'text',
165
  'name' => 'fields[' . $key . '][height]',
166
- 'value' => $field['height'],
167
  'class' => 'height dimension',
168
  'placeholder' => 'Height'
169
  ));
153
  do_action('acf/create_field', array(
154
  'type' => 'text',
155
  'name' => 'fields[' . $key . '][width]',
156
+ 'value' => isset($field['width']) ? $field['width'] : '',
157
  'class' => 'width dimension',
158
  'placeholder' => 'Width'
159
  ));
163
  do_action('acf/create_field', array(
164
  'type' => 'text',
165
  'name' => 'fields[' . $key . '][height]',
166
+ 'value' => isset($field['height']) ? $field['height'] : '',
167
  'class' => 'height dimension',
168
  'placeholder' => 'Height'
169
  ));
acf-image-crop-v5.php CHANGED
@@ -316,6 +316,7 @@ class acf_field_image_crop extends acf_field_image {
316
  // vars
317
  $div_atts = array(
318
  'class' => 'acf-image-uploader acf-cf acf-image-crop',
 
319
  'data-crop_type' => $field['crop_type'],
320
  'data-target_size' => $field['target_size'],
321
  'data-width' => $width,
@@ -373,7 +374,7 @@ class acf_field_image_crop extends acf_field_image {
373
  </div>
374
  </div>
375
  <div class="view hide-if-value">
376
- <p><?php _e('No image selected','acf'); ?> <a data-name="add" class="acf-button" href="#"><?php _e('Add Image','acf'); ?></a></p>
377
  </div>
378
  </div>
379
  <?php
@@ -737,9 +738,8 @@ class acf_field_image_crop extends acf_field_image {
737
  // added
738
  // a function that sets theoptions value to false
739
  function validateImageCropSettingsSection($input) {
740
- $input['hide_cropped'] = ( $input['hide_cropped'] == true ? true : false );
741
- $input['retina_mode'] = ( $input['retina_mode'] == true ? true : false );
742
-
743
  return $input;
744
  }
745
  // added END
316
  // vars
317
  $div_atts = array(
318
  'class' => 'acf-image-uploader acf-cf acf-image-crop',
319
+ 'data-field-settings' => json_encode($field),
320
  'data-crop_type' => $field['crop_type'],
321
  'data-target_size' => $field['target_size'],
322
  'data-width' => $width,
374
  </div>
375
  </div>
376
  <div class="view hide-if-value">
377
+ <p><?php _e('No image selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add Image','acf'); ?></a></p>
378
  </div>
379
  </div>
380
  <?php
738
  // added
739
  // a function that sets theoptions value to false
740
  function validateImageCropSettingsSection($input) {
741
+ $input['hide_cropped'] = ( isset( $input['hide_cropped'] ) && $input['hide_cropped'] == true ? true : false );
742
+ $input['retina_mode'] = ( isset( $input['retina_mode'] ) && $input['retina_mode'] == true ? true : false );
 
743
  return $input;
744
  }
745
  // added END
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.4.7
7
  Author: Anders Thorborg
8
  Author URI: http://thorb.org
9
  License: GPLv2 or later
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.8
7
  Author: Anders Thorborg
8
  Author URI: http://thorb.org
9
  License: GPLv2 or later
js/input.js CHANGED
@@ -368,7 +368,6 @@ function initialize_field( $el ) {
368
  }
369
 
370
  function updateThumbnail($field, img, selection){
371
- console.log('updating thumbnail');
372
  var $options = $field.find('.acf-image-uploader');
373
  var div = $field.find('.crop-preview .preview');
374
  var targetWidth = $field.find('.crop-preview .preview').width();
368
  }
369
 
370
  function updateThumbnail($field, img, selection){
 
371
  var $options = $field.find('.acf-image-uploader');
372
  var div = $field.find('.crop-preview .preview');
373
  var targetWidth = $field.find('.crop-preview .preview').width();
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: andersthorborg
3
  Tags: afc, advanced custom fields, image crop, image, crop
4
  Requires at least: 3.5
5
- Tested up to: 4.3.1
6
- Stable tag: 1.4.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,7 +61,11 @@ function my_register_fields()
61
 
62
  == Changelog ==
63
 
64
- = 1.4.6 =
 
 
 
 
65
  * Added compatibility with ACF PRO 5.4.2.2 icons
66
 
67
  = 1.4.6 =
2
  Contributors: andersthorborg
3
  Tags: afc, advanced custom fields, image crop, image, crop
4
  Requires at least: 3.5
5
+ Tested up to: 4.6
6
+ Stable tag: 1.4.8
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.8 =
65
+ * Fix button styling
66
+ * Prevent php warnings for unset field settings
67
+
68
+ = 1.4.7 =
69
  * Added compatibility with ACF PRO 5.4.2.2 icons
70
 
71
  = 1.4.6 =