Crop-Thumbnails - Version 0.10.9

Version Description

  • bugfix click on the button in the featured image box (WP 4.6 and above)
  • button in featured image box is no longer visible if no image is choosed
  • minor style improvements
Download this release

Release Info

Developer Volkmar Kantor
Plugin Icon Crop-Thumbnails
Version 0.10.9
Comparing to
See all releases

Code changes from version 0.10.8 to 0.10.9

crop-thumbnails.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://wordpress.org/extend/plugins/crop-thumbnails/
5
  * Author: Volkmar Kantor
6
  * Author URI: http://www.totalmedial.de
7
- * Version: 0.10.8
8
  * Description: Crop your thumbnails, the easy way.
9
  * Text Domain: crop-thumbnails
10
  *
@@ -27,7 +27,7 @@
27
 
28
  //cpt - stands for crop-post-thumbnail
29
  define('CROP_THUMBS_LANG','cpt_lang');
30
- define('CROP_THUMBS_VERSION','0.10.8');
31
 
32
  function cpt_plugin_init() {
33
  load_plugin_textdomain( CROP_THUMBS_LANG, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
4
  * Plugin URI: http://wordpress.org/extend/plugins/crop-thumbnails/
5
  * Author: Volkmar Kantor
6
  * Author URI: http://www.totalmedial.de
7
+ * Version: 0.10.9
8
  * Description: Crop your thumbnails, the easy way.
9
  * Text Domain: crop-thumbnails
10
  *
27
 
28
  //cpt - stands for crop-post-thumbnail
29
  define('CROP_THUMBS_LANG','cpt_lang');
30
+ define('CROP_THUMBS_VERSION','0.10.9');
31
 
32
  function cpt_plugin_init() {
33
  load_plugin_textdomain( CROP_THUMBS_LANG, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
css/options.css CHANGED
@@ -7,6 +7,21 @@
7
  #cpt_quicktest strong.fails { background:#cc0000; }
8
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**** MODAL - DIALOG ****/
11
  .cropThumbnailModal { z-index:999999999 !important; }
12
  .cropThumbnailModalOverlay { z-index:999999998 !important; }
7
  #cpt_quicktest strong.fails { background:#cc0000; }
8
 
9
 
10
+ /**** button icon ****/
11
+ a.cropThumbnailsLink .wp-media-buttons-icon::before { content: "\f165"; font: normal 12px/1 dashicons; speak: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
12
+ /* buttons above editor */
13
+ #wp-content-media-buttons a.cropThumbnailsLink .wp-media-buttons-icon::before { font: normal 18px/1 dashicons; }
14
+
15
+
16
+ /**** featured image box ****/
17
+ #postimagediv.closed .cropFeaturedImageWrap { display: none; }
18
+ #postimagediv .cropFeaturedImageWrap { padding:0 12px; margin-top:0; }
19
+
20
+ /**** button in media dialog ****/
21
+ .media-modal .compat-field-cropthumbnails th { width: 0; min-width: 0; margin:0; }
22
+ .media-modal .compat-field-cropthumbnails td { width: auto; }
23
+
24
+
25
  /**** MODAL - DIALOG ****/
26
  .cropThumbnailModal { z-index:999999999 !important; }
27
  .cropThumbnailModalOverlay { z-index:999999998 !important; }
functions/backendpreparer.php CHANGED
@@ -68,6 +68,52 @@ jQuery(document).ready(function($) {
68
  }
69
  };
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  /** add link on posts and pages **/
72
  if ($('body.post-php, body.page-php, body.page-new.php, body.post-new-php').length > 0) {
73
  var post_id_hidden = $('form#post #post_ID');
@@ -79,32 +125,12 @@ jQuery(document).ready(function($) {
79
  * add link on top of editor *
80
  */
81
  var buttonContent = '';
82
- buttonContent+= '<a ';
83
- buttonContent+= 'class="button cropThumbnailBox" href="#" data-cropthumbnail=\'{"post_id":'+ post_id_hidden +'}\' ';
84
- buttonContent+= 'title="<?php esc_attr_e('Crop Thumbnails',CROP_THUMBS_LANG) ?>"';
85
- buttonContent+= '>';
86
- buttonContent+= '<span class="dashicons dashicons-image-crop" style="color:#82878C;font-size: 14px;vertical-align: middle;"></span>';
87
- buttonContent+= '<?php esc_html_e('Crop Thumbnails',CROP_THUMBS_LANG); ?>';
88
  buttonContent+= '</a>';
89
  $('#wp-content-media-buttons').append(buttonContent);
90
 
91
-
92
- /**
93
- * add link to featured image box *
94
- */
95
- buttonContent = '';
96
- buttonContent+= '<a ';
97
- buttonContent+= 'class="button cropThumbnailBox" href="#" data-cropthumbnail=\'{"image_by_post_id":'+ post_id_hidden +',"viewmode":"single"}\' ';
98
- buttonContent+= 'title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>"';
99
- buttonContent+= '>';
100
- buttonContent+= '<span class="dashicons dashicons-image-crop" style="color:#82878C;font-size: 14px;vertical-align: middle;"></span>';
101
- buttonContent+= '<?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?>';
102
- buttonContent+= '</a>';
103
-
104
-
105
- var featuredImageLink = $(buttonContent).css({'margin':'5px', 'padding':'5px','display':'inline-block','line-height':'1.2'});
106
- $('#postimagediv .inside').after(featuredImageLink);
107
-
108
 
109
  $('body').on('cropThumbnailModalClosed',function() {
110
  //lets cache-break the crop-thumbnail-preview-box
@@ -122,12 +148,8 @@ jQuery(document).ready(function($) {
122
  last_span.append(' | ');
123
 
124
  var buttonContent = '';
125
- buttonContent+= '<a ';
126
- buttonContent+= 'class="cropThumbnailBox" href="#" data-cropthumbnail=\'{"image_id":'+ post_id +',"viewmode":"single"}\' ';
127
- buttonContent+= 'title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>"';
128
- buttonContent+= '>';
129
- buttonContent+= '<span class="dashicons dashicons-image-crop" style="color:#82878C;font-size: 14px;vertical-align: middle;"></span>';
130
- buttonContent+= '<?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?>';
131
  buttonContent+= '</a>';
132
 
133
 
@@ -141,10 +163,10 @@ jQuery(document).ready(function($) {
141
  }
142
 
143
  /**
144
- * Create Listener for click-events with element-class ".cropThumbnailBox".
145
  * Open the modal box.
146
  */
147
- $(document).on('click', '.cropThumbnailBox', function(e) {
148
  e.preventDefault();
149
 
150
  <?php
@@ -250,9 +272,8 @@ jQuery(document).ready(function($) {
250
 
251
  if(in_array($post->post_mime_type,$this->allowedMime)) {
252
  $html = '';
253
- $html.= '<a class="button cropThumbnailBox" href="#" data-cropthumbnail=\'{"image_id":'.$post->ID.',"viewmode":"single"}\' ';
254
- $html.= 'title="'.esc_attr__('Crop Featured Image',CROP_THUMBS_LANG).'">';
255
- $html.= '<span class="dashicons dashicons-image-crop" style="color:#82878C;font-size: 14px;vertical-align: middle;"></span>'.esc_html__('Crop Featured Image',CROP_THUMBS_LANG);
256
  $html.= '</a>';
257
 
258
  $form_fields['cropthumbnails'] = array(
68
  }
69
  };
70
 
71
+ /**
72
+ * Adds a button to the featured image metabox.
73
+ * The button will be visible only if a featured image is set.
74
+ */
75
+ function handleFeaturedImageBox() {
76
+ /**
77
+ * add link to featured image box
78
+ */
79
+ var baseElem = $('#postimagediv');
80
+ var featuredImageLinkButton = '';
81
+ featuredImageLinkButton+= '<p class="cropFeaturedImageWrap hidden">';
82
+ featuredImageLinkButton+= '<a class="button cropThumbnailsLink" href="#" data-cropthumbnail=\'{"image_id":'+ parseInt(wp.media.featuredImage.get()) +',"viewmode":"single"}\' title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>">';
83
+ featuredImageLinkButton+= '<span class="wp-media-buttons-icon"></span> <?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?>';
84
+ featuredImageLinkButton+= '</a>';
85
+ baseElem.find('.inside').after( $(featuredImageLinkButton) );
86
+
87
+
88
+ function updateCropFeaturedImageButton(currentId) {
89
+ var wrap = baseElem.find('.cropFeaturedImageWrap');
90
+
91
+ if(currentId===-1) {
92
+ wrap.addClass('hidden');
93
+ } else {
94
+ wrap.removeClass('hidden');
95
+ }
96
+ var link = wrap.find('a');
97
+ var data = link.data('cropthumbnail');
98
+ data.image_id = currentId;
99
+ link.data('cropthumbnail',data);
100
+ }
101
+
102
+ wp.media.featuredImage.frame().on( 'select', function(){
103
+ updateCropFeaturedImageButton( parseInt(wp.media.featuredImage.get()) );
104
+ });
105
+
106
+ baseElem.on('click', '#remove-post-thumbnail', function(){
107
+ updateCropFeaturedImageButton(-1);
108
+ });
109
+
110
+ baseElem.on('click', '.handlediv',function() {
111
+
112
+ });
113
+
114
+ updateCropFeaturedImageButton( parseInt(wp.media.featuredImage.get()) );
115
+ }
116
+
117
  /** add link on posts and pages **/
118
  if ($('body.post-php, body.page-php, body.page-new.php, body.post-new-php').length > 0) {
119
  var post_id_hidden = $('form#post #post_ID');
125
  * add link on top of editor *
126
  */
127
  var buttonContent = '';
128
+ buttonContent+= '<a class="button cropThumbnailsLink" href="#" data-cropthumbnail=\'{"post_id":'+ post_id_hidden +'}\' title="<?php esc_attr_e('Crop Thumbnails',CROP_THUMBS_LANG) ?>">';
129
+ buttonContent+= '<span class="wp-media-buttons-icon"></span> <?php esc_html_e('Crop Thumbnails',CROP_THUMBS_LANG); ?>';
 
 
 
 
130
  buttonContent+= '</a>';
131
  $('#wp-content-media-buttons').append(buttonContent);
132
 
133
+ handleFeaturedImageBox();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  $('body').on('cropThumbnailModalClosed',function() {
136
  //lets cache-break the crop-thumbnail-preview-box
148
  last_span.append(' | ');
149
 
150
  var buttonContent = '';
151
+ buttonContent+= '<a class="cropThumbnailsLink" href="#" data-cropthumbnail=\'{"image_id":'+ post_id +',"viewmode":"single"}\' title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>">';
152
+ buttonContent+= '<span class="wp-media-buttons-icon"></span> <?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?>';
 
 
 
 
153
  buttonContent+= '</a>';
154
 
155
 
163
  }
164
 
165
  /**
166
+ * Create Listener for click-events with element-class ".cropThumbnailsLink".
167
  * Open the modal box.
168
  */
169
+ $(document).on('click', '.cropThumbnailsLink', function(e) {
170
  e.preventDefault();
171
 
172
  <?php
272
 
273
  if(in_array($post->post_mime_type,$this->allowedMime)) {
274
  $html = '';
275
+ $html.= '<a class="button cropThumbnailsLink" href="#" data-cropthumbnail=\'{"image_id":'.$post->ID.',"viewmode":"single"}\' title="'.esc_attr__('Crop Featured Image',CROP_THUMBS_LANG).'">';
276
+ $html.= '<span class="wp-media-buttons-icon"></span> '.esc_html__('Crop Featured Image',CROP_THUMBS_LANG);
 
277
  $html.= '</a>';
278
 
279
  $form_fields['cropthumbnails'] = array(
readme.txt CHANGED
@@ -3,22 +3,22 @@ Contributors: volkmar-kantor
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=volkmar%2ekantor%40gmx%2ede&lc=DE&item_name=Volkmar%20Kantor%20%2d%20totalmedial%2ede&item_number=crop%2dthumbnails&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: post-thumbnails, images, media library
5
  Requires at least: 4.0
6
- Tested up to: 4.5
7
  Stable tag: trunk
8
  License: GPL v3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
- "Crop Thumbnails" made it easy to get exacly that specific image-detail you want to show in the automatic cropped post-thumbnails.
12
 
13
  == Description ==
14
 
15
- The plugin enhance functionality to crop your automatic cropped post-thumbnails individuell and simple. It add links in the backend to enter all images you had attached to a post, page or custom-post.
16
- In the Crop-Editor you can choose one or more (if they have the same ratio) imagesizes and cut-off the part of the image you want.
17
 
18
  = Further Features =
19
 
20
  * It is possible to filter the list of available image-sizes (in dependency to post-types) in the settings (Settings > Crop-Thumbnails).
21
- * You could provide your users a custom style for the Editor-Window.
22
 
23
  == Installation ==
24
 
@@ -112,14 +112,19 @@ If you fork and planning to publish the forked plugin, please contact me.
112
 
113
  == Screenshots ==
114
 
115
- 1. You have access to Crop-Thumbnails on post / page / custom-post-types.
116
  2. All images attached to this post, will shown in a overlay. You have to choose the one you want to crop.
117
  3. Choose one or more images (with the same ratio).
118
- 4. Crop-Thumbnails is also integrated in the media library.
119
  5. Choose what image-sizes should be hidden (for what post-types), for better usability.
120
  6. Quicktest on settings-page, to check if your system is correct setup.
121
 
122
  == Changelog ==
 
 
 
 
 
123
  = 0.10.8 =
124
  * change empty-array-definition to be compatible with old PHP-Versions (prior 5.4)
125
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=volkmar%2ekantor%40gmx%2ede&lc=DE&item_name=Volkmar%20Kantor%20%2d%20totalmedial%2ede&item_number=crop%2dthumbnails&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: post-thumbnails, images, media library
5
  Requires at least: 4.0
6
+ Tested up to: 4.6
7
  Stable tag: trunk
8
  License: GPL v3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
+ "Crop Thumbnails" made it easy to get exacly that specific image-detail you want to show in your featured image or gallery image.
12
 
13
  == Description ==
14
 
15
+ The plugin enhance functionality to crop your automatic cropped images individuell and simple. It add buttons to the edit-pages and media-dialog to access a crop-editor.
16
+ In the crop-editor you can choose one or more (if they have the same ratio) imagesizes and cut-off the part of the image you want.
17
 
18
  = Further Features =
19
 
20
  * It is possible to filter the list of available image-sizes (in dependency to post-types) in the settings (Settings > Crop-Thumbnails).
21
+ * You could provide your users a custom style for the Editor-Window (see F.A.Q.).
22
 
23
  == Installation ==
24
 
112
 
113
  == Screenshots ==
114
 
115
+ 1. You have access to the crop-editor on post / page / custom-post-types.
116
  2. All images attached to this post, will shown in a overlay. You have to choose the one you want to crop.
117
  3. Choose one or more images (with the same ratio).
118
+ 4. The crop-editor is also integrated in the media library.
119
  5. Choose what image-sizes should be hidden (for what post-types), for better usability.
120
  6. Quicktest on settings-page, to check if your system is correct setup.
121
 
122
  == Changelog ==
123
+ = 0.10.9 =
124
+ * bugfix click on the button in the featured image box (WP 4.6 and above)
125
+ * button in featured image box is no longer visible if no image is choosed
126
+ * minor style improvements
127
+
128
  = 0.10.8 =
129
  * change empty-array-definition to be compatible with old PHP-Versions (prior 5.4)
130