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

Version Description

  • Fixed migration from image field to not only return image ID
  • Fixed a js error in field settings caused by a change in class names in ACF
Download this release

Release Info

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

Code changes from version 1.4.3 to 1.4.4

acf-image-crop-v4.php CHANGED
@@ -426,11 +426,15 @@ class acf_field_image_crop extends acf_field_image
426
  return false;
427
  }
428
  $data = json_decode($value);
429
- if(!is_object($data)){
430
- return $value;
 
 
 
 
 
 
431
  }
432
-
433
- $value = $data->cropped_image;
434
 
435
  // format
436
  if( $field['save_format'] == 'url' )
426
  return false;
427
  }
428
  $data = json_decode($value);
429
+ if(is_object($data)){
430
+ $value = $data->cropped_image;
431
+ }
432
+ else{
433
+ // We are migrating from a standard image field
434
+ $data = new stdClass();
435
+ $data->cropped_image = $value;
436
+ $data->original_image = $value;
437
  }
 
 
438
 
439
  // format
440
  if( $field['save_format'] == 'url' )
acf-image-crop-v5.php CHANGED
@@ -951,15 +951,21 @@ class acf_field_image_crop extends acf_field_image {
951
  function format_value( $value, $post_id, $field ) {
952
 
953
  // validate
954
- if( !$value )
955
- {
956
  return false;
957
  }
 
958
  $data = json_decode($value);
959
- if(!is_object($data)){
960
- return $value;
 
 
 
 
 
 
 
961
  }
962
- $value = $data->cropped_image;
963
 
964
  // format
965
  if( $field['save_format'] == 'url' )
951
  function format_value( $value, $post_id, $field ) {
952
 
953
  // validate
954
+ if( !$value ){
 
955
  return false;
956
  }
957
+
958
  $data = json_decode($value);
959
+
960
+ if(is_object($data)){
961
+ $value = $data->cropped_image;
962
+ }
963
+ else{
964
+ // We are migrating from a standard image field
965
+ $data = new stdClass();
966
+ $data->cropped_image = $value;
967
+ $data->original_image = $value;
968
  }
 
969
 
970
  // format
971
  if( $field['save_format'] == 'url' )
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.3
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.4
7
  Author: Anders Thorborg
8
  Author URI: http://thorb.org
9
  License: GPLv2 or later
js/options.js CHANGED
@@ -1,27 +1,27 @@
1
  jQuery(function($){
2
  acf.add_action('append', function(){
3
- $('.field_type-image_crop .target-size-select').each(function() {
4
  toggleCustomDimensions(this);
5
  });
6
- $('.field_type-image_crop .save-in-media-library-select input').each(function() {
7
  //console.log(this);
8
  toggleSaveFormats(this);
9
  });
10
  });
11
 
12
- $(document).on('change', '.field_type-image_crop .target-size-select', function(e) {
13
  toggleCustomDimensions(this);
14
  });
15
 
16
- // $(document).on('change', '.field_type-image_crop .crop-type-select', function(e) {
17
- // $(this).parents('.field_type-image_crop').find('.dimensions-wrap .dimensions-description').addClass('hidden');
18
- // $(this).parents('.field_type-image_crop').find('.dimensions-wrap .dimensions-description[data-type=' + $(this).val() + ']').removeClass('hidden');
19
  // });
20
 
21
- $(document).on('click', '.field_type-image_crop .save-in-media-library-select input', function(e) {
22
  toggleSaveFormats(this);
23
  // var saveToMedia = $(this).val() == 'yes';
24
- // var $returnValueField = $(this).parents('.field_type-image_crop').find('.return-value-select');
25
  // if(! saveToMedia){
26
  // $returnValueField.find('input[value=id], input[value=object]').attr('disabled', true).parents('label').addClass('disabled');
27
  // $returnValueField.find('input[value=url]').attr('checked', true);
@@ -30,15 +30,15 @@ jQuery(function($){
30
  // $returnValueField.find('input').removeAttr('disabled').parents('label').removeClass('disabled');
31
  // }
32
 
33
- // $(this).parents('.field_type-image_crop').find('.dimensions-wrap .dimensions-description').addClass('hidden');
34
- // $(this).parents('.field_type-image_crop').find('.dimensions-wrap .dimensions-description[data-type=' + $(this).val() + ']').removeClass('hidden');
35
 
36
  });
37
 
38
  function toggleSaveFormats(saveToMediaSelect){
39
  if($(saveToMediaSelect).is(':checked')){
40
  var saveToMedia = $(saveToMediaSelect).val() == 'yes';
41
- var $returnValueField = $(saveToMediaSelect).parents('.field_type-image_crop').find('.return-value-select');
42
  if(! saveToMedia){
43
  $returnValueField.find('input[value=id]').attr('disabled', true).parents('label').addClass('disabled');
44
  if($returnValueField.find('input[value=id]').is(':checked')){
@@ -53,21 +53,21 @@ jQuery(function($){
53
 
54
  function toggleCustomDimensions(targetSizeSelect){
55
  if($(targetSizeSelect).val() == 'custom'){
56
- $(targetSizeSelect).parents('.field_type-image_crop').first().find('.custom-target-dimension').each(function(){
57
  $(this).parents('tr.acf-field').first().removeClass('hidden');
58
  });
59
  }
60
  else{
61
- $(targetSizeSelect).parents('.field_type-image_crop').first().find('.custom-target-dimension').each(function(){
62
  $(this).parents('tr.acf-field').first().addClass('hidden');
63
  });
64
  }
65
  }
66
 
67
- $('.field_type-image_crop .target-size-select').each(function() {
68
  toggleCustomDimensions(this);
69
  });
70
- $('.field_type-image_crop .save-in-media-library-select input').each(function() {
71
  toggleSaveFormats(this);
72
  });
73
 
1
  jQuery(function($){
2
  acf.add_action('append', function(){
3
+ $('.acf-field-object-image-crop .target-size-select').each(function() {
4
  toggleCustomDimensions(this);
5
  });
6
+ $('.acf-field-object-image-crop .save-in-media-library-select input').each(function() {
7
  //console.log(this);
8
  toggleSaveFormats(this);
9
  });
10
  });
11
 
12
+ $(document).on('change', '.acf-field-object-image-crop .target-size-select', function(e) {
13
  toggleCustomDimensions(this);
14
  });
15
 
16
+ // $(document).on('change', '.acf-field-object-image-crop .crop-type-select', function(e) {
17
+ // $(this).parents('.acf-field-object-image-crop').find('.dimensions-wrap .dimensions-description').addClass('hidden');
18
+ // $(this).parents('.acf-field-object-image-crop').find('.dimensions-wrap .dimensions-description[data-type=' + $(this).val() + ']').removeClass('hidden');
19
  // });
20
 
21
+ $(document).on('click', '.acf-field-object-image-crop .save-in-media-library-select input', function(e) {
22
  toggleSaveFormats(this);
23
  // var saveToMedia = $(this).val() == 'yes';
24
+ // var $returnValueField = $(this).parents('.acf-field-object-image-crop').find('.return-value-select');
25
  // if(! saveToMedia){
26
  // $returnValueField.find('input[value=id], input[value=object]').attr('disabled', true).parents('label').addClass('disabled');
27
  // $returnValueField.find('input[value=url]').attr('checked', true);
30
  // $returnValueField.find('input').removeAttr('disabled').parents('label').removeClass('disabled');
31
  // }
32
 
33
+ // $(this).parents('.acf-field-object-image-crop').find('.dimensions-wrap .dimensions-description').addClass('hidden');
34
+ // $(this).parents('.acf-field-object-image-crop').find('.dimensions-wrap .dimensions-description[data-type=' + $(this).val() + ']').removeClass('hidden');
35
 
36
  });
37
 
38
  function toggleSaveFormats(saveToMediaSelect){
39
  if($(saveToMediaSelect).is(':checked')){
40
  var saveToMedia = $(saveToMediaSelect).val() == 'yes';
41
+ var $returnValueField = $(saveToMediaSelect).parents('.acf-field-object-image-crop').find('.return-value-select');
42
  if(! saveToMedia){
43
  $returnValueField.find('input[value=id]').attr('disabled', true).parents('label').addClass('disabled');
44
  if($returnValueField.find('input[value=id]').is(':checked')){
53
 
54
  function toggleCustomDimensions(targetSizeSelect){
55
  if($(targetSizeSelect).val() == 'custom'){
56
+ $(targetSizeSelect).parents('.acf-field-object-image-crop').first().find('.custom-target-dimension').each(function(){
57
  $(this).parents('tr.acf-field').first().removeClass('hidden');
58
  });
59
  }
60
  else{
61
+ $(targetSizeSelect).parents('.acf-field-object-image-crop').first().find('.custom-target-dimension').each(function(){
62
  $(this).parents('tr.acf-field').first().addClass('hidden');
63
  });
64
  }
65
  }
66
 
67
+ $('.acf-field-object-image-crop .target-size-select').each(function() {
68
  toggleCustomDimensions(this);
69
  });
70
+ $('.acf-field-object-image-crop .save-in-media-library-select input').each(function() {
71
  toggleSaveFormats(this);
72
  });
73
 
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.1.1
6
- Stable tag: 1.4.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,6 +61,10 @@ function my_register_fields()
61
 
62
  == Changelog ==
63
 
 
 
 
 
64
  = 1.4.3 =
65
  * Removed unused assets
66
 
3
  Tags: afc, advanced custom fields, image crop, image, crop
4
  Requires at least: 3.5
5
  Tested up to: 4.1.1
6
+ Stable tag: 1.4.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.4 =
65
+ * Fixed migration from image field to not only return image ID
66
+ * Fixed a js error in field settings caused by a change in class names in ACF
67
+
68
  = 1.4.3 =
69
  * Removed unused assets
70