Crop-Thumbnails - Version 0.8.2

Version Description

  • add filter for customize the style of the crop-thumbnail content ('crop_post_thumbnail_window_css')
  • add a fix for dynamic height/width images (http://wordpress.org/support/topic/dynamic-widthheight)
  • add ukrainian lang (thanks to Jurko Chervony from www.skinik.name)
Download this release

Release Info

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

Code changes from version 0.8.1 to 0.8.2

crop-thumbnails.php CHANGED
@@ -1,50 +1,50 @@
1
- <?php
2
- /**
3
- * Plugin name: Crop Thumbnails
4
- * Plugin URI: http://wordpress.org/extend/plugins/crop-thumbnails/
5
- * Author: Volkmar Kantor
6
- * Author URI: http://www.totalmedial.de
7
- * Version: 0.8.1
8
- * Description: Crop your thumbnails, the easy way.
9
- *
10
- * License: GPL v3
11
- * Copyright 2012 Volkmar Kantor (email : info@totalmedial.de)
12
-
13
- * This program is free software: you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation, either version 3 of the License, or
16
- * (at your option) any later version.
17
-
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
- */
26
-
27
- //cpt - stands for crop-post-thumbnail
28
- define('CROP_THUMBS_LANG','cpt_lang');
29
- define('CROP_THUMBS_VERSION','0.8.0');
30
-
31
- function cpt_plugin_init() {
32
- load_plugin_textdomain( CROP_THUMBS_LANG, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
33
-
34
- __('Crop your thumbnails, the easy way.');//have to be the same as the plugins-description - for automatic integration into poedit
35
- }
36
- add_action('plugins_loaded', 'cpt_plugin_init');
37
-
38
- /**
39
- * returns the WpVersion in as a float
40
- */
41
- function cptGetWpVersion() {
42
- $version = get_bloginfo('version');
43
- $version = floatval(substr($version,0,3));
44
- return $version;
45
- }
46
-
47
- include_once(dirname(__FILE__).'/functions/settings.php');
48
- include_once(dirname(__FILE__).'/functions/editor.php');
49
- include_once(dirname(__FILE__).'/functions/save.php');
50
  ?>
1
+ <?php
2
+ /**
3
+ * Plugin name: Crop Thumbnails
4
+ * Plugin URI: http://wordpress.org/extend/plugins/crop-thumbnails/
5
+ * Author: Volkmar Kantor
6
+ * Author URI: http://www.totalmedial.de
7
+ * Version: 0.8.2
8
+ * Description: Crop your thumbnails, the easy way.
9
+ *
10
+ * License: GPL v3
11
+ * Copyright 2012 Volkmar Kantor (email : info@totalmedial.de)
12
+
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ //cpt - stands for crop-post-thumbnail
28
+ define('CROP_THUMBS_LANG','cpt_lang');
29
+ define('CROP_THUMBS_VERSION','0.8.2');
30
+
31
+ function cpt_plugin_init() {
32
+ load_plugin_textdomain( CROP_THUMBS_LANG, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
33
+
34
+ __('Crop your thumbnails, the easy way.');//have to be the same as the plugins-description - for automatic integration into poedit
35
+ }
36
+ add_action('plugins_loaded', 'cpt_plugin_init');
37
+
38
+ /**
39
+ * returns the WpVersion in as a float
40
+ */
41
+ function cptGetWpVersion() {
42
+ $version = get_bloginfo('version');
43
+ $version = floatval(substr($version,0,3));
44
+ return $version;
45
+ }
46
+
47
+ include_once(dirname(__FILE__).'/functions/settings.php');
48
+ include_once(dirname(__FILE__).'/functions/editor.php');
49
+ include_once(dirname(__FILE__).'/functions/save.php');
50
  ?>
css/cpt-window.css CHANGED
@@ -1,39 +1,39 @@
1
- .cpt-crop-view { position: relative; }
2
-
3
- .listEmptyMsg { font-size:1.5em; text-align:center; padding:2em;}
4
- .image-list .entry.post-thumbnail { border-color:#aad6f4; background-color:#efefef; }
5
- .image-list { margin:0;padding:0;}
6
- .image-list .entry { width:140px; float:left; border:1px solid #efefef; margin:5px;}
7
- .image-list .entry h3 { font-weight: normal; font-size:1em; margin:0 5px; }
8
- .image-list .entry img { width:130px; height:130px; margin:5px; }
9
- .image-list .cursor, .image-list .cursor * { cursor:pointer;}
10
-
11
- .header {background-color:#efefef; padding:5px; position: relative; z-index: 1000;}
12
- .cpt-crop-view .cptRightPane {width:300px; float:right; border-left:3px solid #efefef; padding:5px 5px 0 10px; }
13
- .thumbnail-list { border-top: 3px solid #efefef; padding-top:5px; margin-top:5px; }
14
- .thumbnail-list li { padding:5px; border:1px solid white; cursor:pointer; }
15
- .thumbnail-list li:hover { border:1px solid #aad6f4; }
16
- .thumbnail-list li.active { background-color:#aad6f4; border:1px solid #aad6f4; }
17
- .thumbnail-list li span { display:block; font-size:0.8em; }
18
- .thumbnail-list li img { max-width:100%; height: auto; max-height:250px;}
19
- .thumbnail-list li .lowResWarning,
20
- .thumbnail-list li .badParameterWarning { font-style: italic; color:#990000;}
21
-
22
- .lbl-cpt-same-ratio {font-size:0.9em;}
23
-
24
- .selectionArea { width:300px; padding:5px; float:left; }
25
- .selectionArea img { max-width:300px; height:auto; }
26
- .selectionArea h3 { margin:0;}
27
- #cpt-generate { width: 300px; height:2em; padding:0.5em 0; display:block; line-height: 0;}
28
-
29
- h4 { margin-bottom:0em;}
30
- .step-info { font-size:0.9em; }
31
-
32
-
33
- .postTypeDisabledMsg, .waitingWindow { font-size: 2em; font-weight:bold; width: 100%; height:10em; text-align: center; padding: 3em 0; background: transparent url(../images/loading.gif) no-repeat center center; }
34
- .postTypeDisabledMsg { background: none; }
35
-
36
- .cpt-debug {clear: left; padding-left:5px;}
37
- .cpt-debug .cpt-debug-handle { border:1px solid #aaa; background-color:#f1f1f1; padding:0.3em 1em;}
38
- .cpt-debug.closed .content { display:none; }
39
- .cpt-debug .content { font-family: monospace;margin-top:0.5em; }
1
+ .cpt-crop-view { position: relative; }
2
+
3
+ .listEmptyMsg { font-size:1.5em; text-align:center; padding:2em;}
4
+ .image-list .entry.post-thumbnail { border-color:#aad6f4; background-color:#efefef; }
5
+ .image-list { margin:0;padding:0;}
6
+ .image-list .entry { width:140px; float:left; border:1px solid #efefef; margin:5px;}
7
+ .image-list .entry h3 { font-weight: normal; font-size:1em; margin:0 5px; }
8
+ .image-list .entry img { width:130px; height:130px; margin:5px; }
9
+ .image-list .cursor, .image-list .cursor * { cursor:pointer;}
10
+
11
+ .header {background-color:#efefef; padding:5px; position: relative; z-index: 1000;}
12
+ .cpt-crop-view .cptRightPane {width:300px; float:right; border-left:3px solid #efefef; padding:5px 5px 0 10px; }
13
+ .thumbnail-list { border-top: 3px solid #efefef; padding-top:5px; margin-top:5px; }
14
+ .thumbnail-list li { padding:5px; border:1px solid white; cursor:pointer; }
15
+ .thumbnail-list li:hover { border:1px solid #aad6f4; }
16
+ .thumbnail-list li.active { background-color:#aad6f4; border:1px solid #aad6f4; }
17
+ .thumbnail-list li span { display:block; font-size:0.8em; }
18
+ .thumbnail-list li img { max-width:100%; height: auto; max-height:250px;}
19
+ .thumbnail-list li .lowResWarning,
20
+ .thumbnail-list li .badParameterWarning { font-style: italic; color:#990000;}
21
+
22
+ .lbl-cpt-same-ratio {font-size:0.9em;}
23
+
24
+ .selectionArea { width:300px; padding:5px; float:left; }
25
+ .selectionArea img { max-width:300px; height:auto; }
26
+ .selectionArea h3 { margin:0;}
27
+ #cpt-generate { width: 300px; height:2em; padding:0.5em 0; display:block; line-height: 0;}
28
+
29
+ h4 { margin-bottom:0em;}
30
+ .step-info { font-size:0.9em; }
31
+
32
+
33
+ .postTypeDisabledMsg, .waitingWindow { font-size: 2em; font-weight:bold; width: 100%; height:10em; text-align: center; padding: 3em 0; background: transparent url(../images/loading.gif) no-repeat center center; }
34
+ .postTypeDisabledMsg { background: none; }
35
+
36
+ .cpt-debug {clear: left; padding-left:5px;}
37
+ .cpt-debug .cpt-debug-handle { border:1px solid #aaa; background-color:#f1f1f1; padding:0.3em 1em;}
38
+ .cpt-debug.closed .content { display:none; }
39
+ .cpt-debug .content { font-family: monospace;margin-top:0.5em; }
css/options.css CHANGED
@@ -1,2 +1,2 @@
1
- .cpt_settings_paypal { border:1px solid #298CBA; border-radius:3px; background-color:#f6f6f6; max-width:30em; padding:0 0.5em; margin:2em 0; text-align:center; }
2
  .cpt_settings_submit { margin-top:2em; }
1
+ .cpt_settings_paypal { border:1px solid #298CBA; border-radius:3px; background-color:#f6f6f6; max-width:30em; padding:0 0.5em; margin:2em 0; text-align:center; }
2
  .cpt_settings_submit { margin-top:2em; }
functions/editor.php CHANGED
@@ -1,517 +1,530 @@
1
- <?php
2
- class CropPostThumbnailsEditor {
3
-
4
- private $debugOutput = '';
5
-
6
- function __construct() {
7
- if ( is_admin() ) {
8
- //add style and javascript
9
- add_action( 'admin_print_styles', array(&$this, 'adminHeaderCSS') );
10
- add_action( 'admin_print_scripts', array(&$this, 'adminHeaderJS') );
11
- }
12
-
13
- /* for the html inside the thickbox */
14
- add_action('wp_ajax_croppostthumb_ajax', array($this,'ajaxWindow'));
15
- }
16
-
17
-
18
- /**
19
- * this function is called for/from the thickbox - returns ordanary html
20
- */
21
- function ajaxWindow() {
22
- $this->cleanWPHead();
23
- $failure_msg = '';
24
- if(!$this->isUserPermitted()) {
25
- $failure_msg = __('An error happend!',CROP_THUMBS_LANG);
26
- } else {
27
- switch(true) {
28
- case isset($_REQUEST['post_id'])://full programm
29
- $this->listImages();
30
- break;
31
- case isset($_REQUEST['image_id'])://only one image
32
- $this->byImageId();
33
- break;
34
- case isset($_REQUEST['image_by_post_id'])://only one image
35
- $id = get_post_thumbnail_id(intval($_REQUEST['image_by_post_id']));
36
- if(!empty($id)) {
37
- $_REQUEST['image_id'] = $id;
38
- $_REQUEST['parent_post_id'] = intval($_REQUEST['image_by_post_id']);
39
- $this->byImageId();
40
- } else {
41
- $failure_msg = '<div class="listEmptyMsg">'.__('No featured Image set for this post until now.',CROP_THUMBS_LANG).'</div>';
42
- }
43
- break;
44
- default:
45
- $failure_msg = __('An error happend!',CROP_THUMBS_LANG);
46
- break;
47
- }
48
- }
49
-
50
- if(!empty($failure_msg)) {
51
- wp_enqueue_style( 'cpt-window',plugins_url('css/cpt-window.css',dirname(__FILE__)),array('wp-admin'),CROP_THUMBS_VERSION);
52
- $cptContent = $failure_msg;
53
- include_once( dirname(__FILE__).'/../html/template.php' );
54
- }
55
- die();//to prevent to send back a "0"
56
- }
57
-
58
- /**
59
- * Display a list of images that are attached to this post_id.
60
- * Hightlight the post-thumbnail (if it is attached to this post_id)
61
- */
62
- function listImages() {
63
- global $cptSettings;
64
- $options = $cptSettings->getOptions();
65
-
66
- $data = $this->loadPostIdData(intval($_REQUEST['post_id']));
67
-
68
- $parent_post_type = '';
69
- $_tmp_post = get_post(intval($_REQUEST['post_id']));
70
- if(!empty($_tmp_post)) {
71
- $parent_post_type = $_tmp_post->post_type;
72
- }
73
-
74
- $cptContent = '';
75
-
76
- if($this->shouldBeHiddenOnPostType($options,$parent_post_type)) {
77
- $cptContent = '<div class="postTypeDisabledMsg">'.__('Cropping is disabled for this post-type.',CROP_THUMBS_LANG).'</div>';
78
- } elseif($data==false) {
79
- $cptContent = '<div class="listEmptyMsg">'.__('No images in this post yet. You have to upload some via upload dialog.',CROP_THUMBS_LANG).'</div>';
80
- } else {
81
- //the dynamic javascript
82
- ob_start(); ?>
83
- <script>
84
- jQuery(document).ready(function($) {
85
- $('.image-list .entry').click(function() {
86
- var image_id = $(this).attr('rel');
87
- var parent_post_id = <?php echo intval($_REQUEST['post_id']); ?>;
88
- document.location.href = ajaxurl+"?action=croppostthumb_ajax&image_id="+image_id+"&parent_post_id="+parent_post_id;
89
- return;
90
- });
91
- });
92
- </script>
93
- <?php
94
- $cptScript = ob_get_clean();
95
- //END the javascript
96
-
97
-
98
- //the content
99
- ob_start();?>
100
- <div class="header"><strong><?php _e('Choose the image you want to crop.',CROP_THUMBS_LANG); ?></strong></div>
101
- <ul class="image-list">
102
- <?php
103
- $counter = 1;
104
- foreach($data as $key=>$image) : ?>
105
- <li class="entry cursor<?php echo (isset($image->is_post_thumbnail) ? ' post-thumbnail' : ''); ?>" rel="<?php echo $image->ID;?>">
106
- <h3><?php echo (isset($image->is_post_thumbnail) ? __('Post Thumbnail',CROP_THUMBS_LANG) : sprintf(__('Image %d',CROP_THUMBS_LANG),$counter));?></h3>
107
- <?php $img_data = wp_get_attachment_image_src($image->ID, 'thumbnail');?>
108
- <img src="<?php echo $img_data[0].'?'.time(); ?>" />
109
- </li>
110
- <?php
111
- $counter++;
112
- endforeach; ?>
113
- </ul>
114
- <?php
115
- $cptContent = ob_get_clean();
116
- //END the content
117
- }
118
- wp_enqueue_script( 'jquery' );
119
- wp_enqueue_style( 'cpt-window',plugins_url('css/cpt-window.css',dirname(__FILE__)),array('wp-admin'),CROP_THUMBS_VERSION);
120
- include_once( dirname(__FILE__).'/../html/template.php' );
121
- return true;
122
- }
123
-
124
-
125
- /**
126
- * Display the crop editor.
127
- * @param $_REQUEST['image_id'] - ID of the image to show
128
- * @param $_REQUEST['viewmode']=='single' - without the back-link
129
- */
130
- function byImageId() {
131
- global $cptSettings,$content_width;
132
-
133
- //make sure $content_width is out of the way
134
- $_remember_content_width = $content_width;
135
- $content_width = null;
136
-
137
-
138
- $options = $cptSettings->getOptions();
139
- $this->addDebug('options', print_r($options,true));
140
- $image_obj = get_post(intval($_REQUEST['image_id']));
141
-
142
- //$post_id_attached holds the id of the post the image is attached to - can be null/empty
143
- $post_id_attached = -1;
144
- if(!empty($image_obj->post_parent)) {
145
- $post_id_attached=$image_obj->post_parent;
146
- }
147
-
148
- //$current_parent_post_type
149
- $current_parent_post_type = '';
150
- $current_parent_post_id = -1;
151
-
152
- if(!empty($_REQUEST['parent_post_id'])) {
153
- $_tmp = get_post(intval($_REQUEST['parent_post_id']));
154
- if(!empty($_tmp)) {
155
- $current_parent_post_type = $_tmp->post_type;
156
- $current_parent_post_id = $_tmp->ID;
157
- }
158
- }
159
-
160
- $all_image_sizes = $cptSettings->getImageSizes();
161
- $this->addDebug('all_image_sizes', print_r($all_image_sizes,true));
162
-
163
- $orig_img = wp_get_attachment_image_src($image_obj->ID, 'full');
164
- $orig_img['gcd'] = $this->gcd($orig_img[1],$orig_img[2]);
165
- $orig_img['ratio'] = ($orig_img[1]/$orig_img['gcd']) / ($orig_img[2]/$orig_img['gcd']);
166
- $orig_img['print_ratio'] = ($orig_img[1]/$orig_img['gcd']).':'.($orig_img[2]/$orig_img['gcd']);
167
-
168
- $cache_breaker = time();//a additional parameter that will be added to the image-urls to prevent the browser to show a cached image
169
-
170
- $this->addDebug('img-postmeta',print_r(wp_get_attachment_metadata($image_obj->ID, true),true));
171
-
172
- //the javascript
173
- ob_start(); ?>
174
- <script>
175
- jQuery(document).ready(function($) {
176
- cpt_lang = new Object();
177
- cpt_lang['bug'] = "<?php _e('bug - this case shouldnt be happend',CROP_THUMBS_LANG);?>";
178
- cpt_lang['warningOriginalToSmall'] = "<?php _e('Warning: the original image is to small to be cropped in good quality with this thumbnail-size.',CROP_THUMBS_LANG);?>";
179
- cpt_lang['selectOne'] = "<?php _e('First, select one image. Then, click once again.',CROP_THUMBS_LANG);?>";
180
- cpt_ajax_nonce = "<?php echo wp_create_nonce($cptSettings->getNonceBase()); ?>";
181
- cpt_debug_js = <?php echo (!empty($options['debug_js'])) ? 'true;' : 'false;'; ?>
182
- });
183
- </script>
184
- <?php
185
- $cptScript = ob_get_clean();
186
- //END the javascript
187
-
188
- /**
189
- * wether or not to show the "back button"
190
- */
191
- $headline = true;
192
- if(!empty($_REQUEST['viewmode']) && $_REQUEST['viewmode']=='single') {
193
- $headline = false;
194
- }
195
-
196
- //the content
197
- ob_start();
198
-
199
- if($this->shouldBeHiddenOnPostType($options,$current_parent_post_type)) : ?>
200
- <div class="cpt-crop-view">
201
- <div class="postTypeDisabledMsg"><?php _e('Cropping is disabled for this post-type.',CROP_THUMBS_LANG); ?></div>
202
- </div>
203
- <?php else : ?>
204
-
205
- <div class="cpt-crop-view">
206
- <?php if($headline) :?><div class="header"><a class="back" href="<?php echo admin_url( 'admin-ajax.php'); ?>?action=croppostthumb_ajax&post_id=<?php echo $current_parent_post_id; ?>"><?php _e('back to image-list',CROP_THUMBS_LANG); ?></a></div><?php endif; ?>
207
- <div class="waitingWindow hidden"><?php _e('Please wait until the Images are cropped.',CROP_THUMBS_LANG); ?></div>
208
- <div class="mainWindow">
209
- <div class="selectionArea cptLeftPane">
210
- <h3><?php _e('Raw',CROP_THUMBS_LANG); ?>: <?php echo $orig_img[1].' '.__('pixel',CROP_THUMBS_LANG)?> x <?php echo $orig_img[2].' '.__('pixel',CROP_THUMBS_LANG) ?> (<?php echo $orig_img['print_ratio']; ?>)</h3>
211
- <img src="<?php echo $orig_img[0]?>" data-values='{"id":<?php echo $image_obj->ID; ?>,"parentId":<?php echo $post_id_attached ?>,"width":<?php echo $orig_img[1]?>,"height":<?php echo $orig_img[2] ?>}' />
212
- <button id="cpt-generate" class="button"><?php _e('save crop',CROP_THUMBS_LANG);?></button>
213
- <h4><?php _e('Quick-Instructions',CROP_THUMBS_LANG);?></h4>
214
- <ul class="step-info">
215
- <li><?php _e('Step 1: Choose an image from the right.',CROP_THUMBS_LANG); ?></li>
216
- <li><?php _e('Step 2: Use the mouse change the size of the rectangle on the image above.',CROP_THUMBS_LANG); ?></li>
217
- <li><?php _e('Step 3: Click on "save crop".',CROP_THUMBS_LANG); ?></li>
218
- </ul>
219
- </div>
220
- <div class="cptRightPane">
221
- <input type="checkbox" name="cpt-same-ratio" value="1" id="cpt-same-ratio" checked="checked" />
222
- <label for="cpt-same-ratio" class="lbl-cpt-same-ratio"><?php _e('select images with same ratio at once',CROP_THUMBS_LANG); ?></label>
223
- <button id="cpt-deselect" class="button"><?php _e('deselect all',CROP_THUMBS_LANG); ?></button>
224
- <ul class="thumbnail-list">
225
- <?php
226
- foreach($all_image_sizes as $img_size_name=>$value) :
227
- if(!$this->shouldSizeBeHidden($options,$img_size_name,$value,$current_parent_post_type)) :
228
- $ratio = null; //reset
229
- $gcd = null; //reset
230
- $print_ratio = null; //reset
231
- $print_cropped = ''; //reset
232
- $crop = 0; //reset
233
- $special_warning = ''; //reset
234
-
235
- /** define ratio **/
236
- if($value['width'] != 0 && $value['height']!=0) {
237
- $gcd = $this->gcd($value['width'],$value['height']);//get greatest common divisor
238
- $ratio = ($value['width']/$gcd) / ($value['height']/$gcd);//get ratio
239
- $print_ratio = $value['width']/$gcd.':'.$value['height']/$gcd;
240
- } else {
241
- //keep ratio same as original image
242
- $gcd = $orig_img['gcd'];
243
- $ratio = $orig_img['ratio'];
244
- $print_ratio = $orig_img['print_ratio'];
245
- }
246
-
247
-
248
- if(!empty($value['crop'])) {
249
- //cropped
250
- $print_cropped = ' ('.__('cropped',CROP_THUMBS_LANG).')';
251
- $crop = 1;
252
- } else {
253
- //not cropped
254
- /* -- maybe use this behaviour in a later version --
255
- $print_cropped = ' ('.__('maximum',CROP_THUMBS_LANG).')';
256
- $print_ratio = __('free choice',CROP_THUMBS_LANG);
257
- */
258
-
259
- $print_cropped = ' ('.__('maximum',CROP_THUMBS_LANG).')';
260
- $crop = 1;
261
- //keep ratio same as original image
262
- $gcd = $orig_img['gcd'];
263
- $ratio = $orig_img['ratio'];
264
- $print_ratio = $orig_img['print_ratio'];
265
- }
266
-
267
- $print_dimensions = $value['width'].' '.__('pixel',CROP_THUMBS_LANG).' x '.$value['height'].' '.__('pixel',CROP_THUMBS_LANG).$print_cropped;
268
-
269
- $img_data = wp_get_attachment_image_src($image_obj->ID, $img_size_name);
270
-
271
-
272
- $_lowResWarning = '';
273
- if($this->isLowRes($value,$orig_img)) {
274
- $_lowResWarning = ' <span class="lowResWarning">'.__('Original image to small for good crop-quality!',CROP_THUMBS_LANG).'</span>';
275
- }
276
-
277
- ?>
278
- <li rel="<?php echo $print_ratio; ?>">
279
- <strong><?php echo $img_size_name.$_lowResWarning; ?></strong><?php echo $special_warning; ?>
280
- <span class="dimensions"><?php _e('Dimensions:',CROP_THUMBS_LANG) ?> <?php echo $print_dimensions; ?></span>
281
- <span class="ratio"><?php _e('Ratio:',CROP_THUMBS_LANG) ?> <?php echo $print_ratio; ?></span>
282
- <img src="<?php echo $img_data[0]?>?<?php echo $cache_breaker ?>" data-values='{"name":"<?php echo $img_size_name; ?>","width":<?php echo $value['width']; ?>,"height":<?php echo $value['height']; ?>,"ratio":<?php echo $ratio ?>,"crop":<?php echo $crop ?>}' />
283
- </li>
284
- <?php endif; ?>
285
- <?php endforeach; ?>
286
- </ul>
287
- </div>
288
- </div>
289
- </div>
290
- <?php
291
- endif;
292
- $cptContent = ob_get_clean();
293
- $cptContent.= $this->getDebugOutput($options);
294
- //END the content
295
-
296
-
297
- wp_enqueue_script( 'jquery' );
298
- wp_enqueue_script( 'my_jcrop', plugins_url('js/jcrop/js/jquery.Jcrop.min.js',dirname(__FILE__)), array(), CROP_THUMBS_VERSION);
299
- wp_enqueue_script( 'json2' );
300
- wp_enqueue_script( 'cpt-crop', plugins_url('js/cpt-crop.js',dirname(__FILE__)), array('jquery','my_jcrop','json2'), CROP_THUMBS_VERSION);
301
-
302
- wp_enqueue_style( 'cpt-window', plugins_url('css/cpt-window.css',dirname(__FILE__)), array('wp-admin'), CROP_THUMBS_VERSION);
303
- wp_enqueue_style( 'my_jcrop', plugins_url('js/jcrop/css/jquery.Jcrop.min.css',dirname(__FILE__)), array(), CROP_THUMBS_VERSION);
304
-
305
- include_once( dirname(__FILE__).'/../html/template.php' );
306
-
307
- $content_width = $_remember_content_width;//reset the content-width
308
- return true;
309
- }
310
-
311
- function shouldBeHiddenOnPostType($options,$post_type) {
312
- if(empty($post_type)) {
313
- return false;
314
- }
315
- if(empty($options['hide_post_type'][$post_type])) {
316
- return false;
317
- }
318
- return true;
319
- }
320
-
321
- /**
322
- * Check wether or not the image_size should be hidden for this post_type
323
- * @param array options array
324
- * @param string name of the image-size (i.e. post-thumbnail, ...)
325
- * @param string name post-type (i.e. post, page, ...)
326
- * @return boolean true if Image-size should be hidden
327
- */
328
- function shouldSizeBeHidden($options, $img_size_name, $img_size, $post_type='') {
329
- $_return = false;
330
- if(!empty($post_type)) {
331
- //we are NOT in the mediathek
332
-
333
- //-if hide_size
334
- if(!empty($options['hide_size'][$post_type][$img_size_name])) {
335
- $_return = true;
336
- }
337
-
338
- //if not a crop-size and allow_non_cropped
339
- if(empty($img_size['crop']) && empty($options['allow_non_cropped'])) {
340
- $_return = true;
341
- }
342
- } else {
343
- //we are in the mediathek
344
-
345
- //-if not a crop-size and allow_non_cropped
346
- if(empty($img_size['crop']) && empty($options['allow_non_cropped'])) {
347
- $_return = true;
348
- }
349
- }
350
- return $_return;
351
- }
352
-
353
-
354
- /**
355
- * load all image data of that $post_id
356
- * - adds "is_post_thumbnail" with value true into the entry, if it is the post_thumbnail
357
- */
358
- function loadPostIdData($post_id) {
359
- $args = array(
360
- 'post_type' => 'attachment',
361
- 'numberposts' => -1,
362
- 'post_parent' => intval($post_id)
363
- );
364
- $images = get_posts($args);
365
-
366
- $post_thumbnail_id = get_post_thumbnail_id( $post_id );
367
- if(!isset($post_thumbnail_id)) {
368
- $post_thumbnail_id = -1;
369
- }
370
-
371
- foreach($images as $key=>$value) {
372
- $mime = $value->post_mime_type;
373
- if( $mime !='image/jpeg' AND $mime !='image/png') {
374
- unset($images[$key]);
375
- } elseif($value->ID==$post_thumbnail_id) {
376
- $images[$key]->is_post_thumbnail = true;
377
- }
378
- }
379
- return $images;
380
- }
381
-
382
- /**
383
- * Checks if the thumb-image-dimensions are bigger than the actuall image.
384
- * @param array thumbnail-data from the add_image_size-funtion (width, height)
385
- * @param array original image-data-array (url, width, height)
386
- * @return true if the original is smaller than the thumbnail-size
387
- */
388
- function isLowRes($thumb,$orig) {
389
- if($thumb['width']>$orig[1] || $thumb['height']>$orig[2]) {
390
- return true;
391
- }
392
- return false;
393
- }
394
-
395
- function isUserPermitted() {
396
- $return = false;
397
- if(current_user_can('upload_files') && current_user_can('edit_pages')) {
398
- $return = true;
399
- }
400
- //TODO maybe add noence (is it needed? there are no file- or db-operations)
401
- return $return;
402
- }
403
-
404
- /**
405
- * For adding the "thickbox"-style in the mediathek
406
- */
407
- function adminHeaderCSS() {
408
- global $pagenow;
409
- if ( $pagenow == 'post.php'
410
- || $pagenow == 'post-new.php'
411
- || $pagenow == 'page.php'
412
- || $pagenow == 'page-new.php'
413
- || $pagenow == 'upload.php') {
414
- wp_enqueue_style( 'thickbox' );
415
- }
416
- }
417
-
418
-
419
- /**
420
- * For adding the "crop-thumbnail"-link on posts, pages and the mediathek
421
- */
422
- function adminHeaderJS() {
423
- global $pagenow;
424
- if ( $pagenow == 'post.php'
425
- || $pagenow == 'post-new.php'
426
- || $pagenow == 'page.php'
427
- || $pagenow == 'page-new.php'
428
- || $pagenow == 'upload.php') {
429
-
430
- wp_enqueue_script('thickbox', false, array('jquery','jquery-ui-tabs'));
431
- add_action('admin_footer',array($this,'cptAddLinksToAdmin'));
432
- }
433
- }
434
-
435
-
436
- /**
437
- * This is for use inside the plugin only.
438
- * Removes all other styles and scripts, to make sure the crop-thumbnail is not compromited by other plugins
439
- */
440
- function cleanWPHead() {
441
- global $wp_scripts, $wp_styles;
442
- $wp_scripts = new WP_Scripts();
443
- $wp_styles = new WP_Styles();
444
- remove_all_actions('wp_print_styles');
445
- remove_all_actions('wp_print_scripts');
446
- }
447
-
448
- /**
449
- * Greatest cummon divisor
450
- */
451
- function gcd($a, $b){
452
- $b = ( $a == 0 )? 0 : $b;
453
- return ( $a % $b )? $this->gcd($b, abs($a - $b)) : $b;
454
- }
455
-
456
-
457
- function addDebug($title, $output) {
458
- $this->debugOutput.= '---'.$title.'---<br />'.$output.'<br />';
459
- }
460
-
461
-
462
- function getDebugOutput($options) {
463
- if(!empty($options['debug_data'])) {
464
- return '<div class="cpt-debug closed"><a class="cpt-debug-handle" href="#">show debug</a><div class="content">'.nl2br(str_replace(" ","&nbsp;&nbsp;",$this->debugOutput)).'</div></div>';
465
- }
466
- return '';
467
- }
468
-
469
-
470
- /**
471
- * adds the links into post-types and the media-library
472
- */
473
- function cptAddLinksToAdmin() {
474
- ?>
475
- <script type="text/javascript">
476
- jQuery(document).ready(function($) {
477
- var boxViewportHeight = $(window).height() - 100;
478
- //add link on posts and pages
479
- if ($('body.post-php, body.page-php, body.page-new.php, body.post-new-php').length > 0) {
480
- var post_id_hidden = $('form#post #post_ID');
481
- if (post_id_hidden) {
482
-
483
- post_id_hidden = parseInt(post_id_hidden.val());
484
-
485
- /** add link on top of editor **/
486
- $('#wp-content-media-buttons').append('<a style="margin:0 2em;" class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;post_id=' + post_id_hidden + '&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Thumbnails',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Thumbnails',CROP_THUMBS_LANG); ?></a>');
487
-
488
-
489
- /** add link to featured image box **/
490
- var featuredImageLink = $('<a class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;image_by_post_id=' + post_id_hidden + '&amp;viewmode=single&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?></a>')
491
- .css({'margin':'5px', 'padding':'5px','display':'inline-block','line-height':'1'})
492
- .addClass('button');
493
- $('#postimagediv .inside').after(featuredImageLink);
494
- }
495
- }
496
-
497
- /** add link on mediathek **/
498
- if ($('body.upload-php').length > 0) {
499
- $('#the-list tr').each(function() {
500
- if ($(this).find('td.media-icon img').attr('src').lastIndexOf("/wp-includes/images/") == -1) {
501
- var post_id = parseInt($(this).attr('id').substr(5));
502
- var last_span = $(this).find('.column-title .row-actions span:last-child');
503
- last_span.append(' | ');
504
- last_span.parent().append('<a class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;image_id=' + post_id + '&amp;viewmode=single&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Thumbnail',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Thumbnail',CROP_THUMBS_LANG); ?></a>')
505
- }
506
- });
507
- }
508
- });
509
- </script>
510
- <?php
511
- }
512
- }
513
-
514
-
515
-
516
- $cpte = new CropPostThumbnailsEditor();
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  ?>
1
+ <?php
2
+ class CropPostThumbnailsEditor {
3
+
4
+ private $debugOutput = '';
5
+
6
+ function __construct() {
7
+ if ( is_admin() ) {
8
+ //add style and javascript
9
+ add_action( 'admin_print_styles', array(&$this, 'adminHeaderCSS') );
10
+ add_action( 'admin_print_scripts', array(&$this, 'adminHeaderJS') );
11
+ }
12
+
13
+ /* for the html inside the thickbox */
14
+ add_action('wp_ajax_croppostthumb_ajax', array($this,'ajaxWindow'));
15
+ }
16
+
17
+
18
+ /**
19
+ * this function is called for/from the thickbox - returns ordanary html
20
+ */
21
+ function ajaxWindow() {
22
+ $this->cleanWPHead();
23
+ $failure_msg = '';
24
+ if(!$this->isUserPermitted()) {
25
+ $failure_msg = __('An error happend!',CROP_THUMBS_LANG);
26
+ } else {
27
+ switch(true) {
28
+ case isset($_REQUEST['post_id'])://full programm
29
+ $this->listImages();
30
+ break;
31
+ case isset($_REQUEST['image_id'])://only one image
32
+ $this->byImageId();
33
+ break;
34
+ case isset($_REQUEST['image_by_post_id'])://only one image
35
+ $id = get_post_thumbnail_id(intval($_REQUEST['image_by_post_id']));
36
+ if(!empty($id)) {
37
+ $_REQUEST['image_id'] = $id;
38
+ $_REQUEST['parent_post_id'] = intval($_REQUEST['image_by_post_id']);
39
+ $this->byImageId();
40
+ } else {
41
+ $failure_msg = '<div class="listEmptyMsg">'.__('No featured Image set for this post until now.',CROP_THUMBS_LANG).'</div>';
42
+ }
43
+ break;
44
+ default:
45
+ $failure_msg = __('An error happend!',CROP_THUMBS_LANG);
46
+ break;
47
+ }
48
+ }
49
+
50
+ if(!empty($failure_msg)) {
51
+ $windowCssPath = apply_filters('crop_post_thumbnail_window_css', plugins_url('css/cpt-window.css',dirname(__FILE__)));
52
+ wp_enqueue_style( 'cpt-window',$windowCssPath,array('wp-admin'),CROP_THUMBS_VERSION);
53
+ $cptContent = $failure_msg;
54
+ include_once( dirname(__FILE__).'/../html/template.php' );
55
+ }
56
+ die();//to prevent to send back a "0"
57
+ }
58
+
59
+ /**
60
+ * Display a list of images that are attached to this post_id.
61
+ * Hightlight the post-thumbnail (if it is attached to this post_id)
62
+ */
63
+ function listImages() {
64
+ global $cptSettings;
65
+ $options = $cptSettings->getOptions();
66
+
67
+ $data = $this->loadPostIdData(intval($_REQUEST['post_id']));
68
+
69
+ $parent_post_type = '';
70
+ $_tmp_post = get_post(intval($_REQUEST['post_id']));
71
+ if(!empty($_tmp_post)) {
72
+ $parent_post_type = $_tmp_post->post_type;
73
+ }
74
+
75
+ $cptContent = '';
76
+
77
+ if($this->shouldBeHiddenOnPostType($options,$parent_post_type)) {
78
+ $cptContent = '<div class="postTypeDisabledMsg">'.__('Cropping is disabled for this post-type.',CROP_THUMBS_LANG).'</div>';
79
+ } elseif($data==false) {
80
+ $cptContent = '<div class="listEmptyMsg">'.__('No images in this post yet. You have to upload some via upload dialog.',CROP_THUMBS_LANG).'</div>';
81
+ } else {
82
+ //the dynamic javascript
83
+ ob_start(); ?>
84
+ <script>
85
+ jQuery(document).ready(function($) {
86
+ $('.image-list .entry').click(function() {
87
+ var image_id = $(this).attr('rel');
88
+ var parent_post_id = <?php echo intval($_REQUEST['post_id']); ?>;
89
+ document.location.href = ajaxurl+"?action=croppostthumb_ajax&image_id="+image_id+"&parent_post_id="+parent_post_id;
90
+ return;
91
+ });
92
+ });
93
+ </script>
94
+ <?php
95
+ $cptScript = ob_get_clean();
96
+ //END the javascript
97
+
98
+
99
+ //the content
100
+ ob_start();?>
101
+ <div class="header"><strong><?php _e('Choose the image you want to crop.',CROP_THUMBS_LANG); ?></strong></div>
102
+ <ul class="image-list">
103
+ <?php
104
+ $counter = 1;
105
+ foreach($data as $key=>$image) : ?>
106
+ <li class="entry cursor<?php echo (isset($image->is_post_thumbnail) ? ' post-thumbnail' : ''); ?>" rel="<?php echo $image->ID;?>">
107
+ <h3><?php echo (isset($image->is_post_thumbnail) ? __('Post Thumbnail',CROP_THUMBS_LANG) : sprintf(__('Image %d',CROP_THUMBS_LANG),$counter));?></h3>
108
+ <?php $img_data = wp_get_attachment_image_src($image->ID, 'thumbnail');?>
109
+ <img src="<?php echo $img_data[0].'?'.time(); ?>" />
110
+ </li>
111
+ <?php
112
+ $counter++;
113
+ endforeach; ?>
114
+ </ul>
115
+ <?php
116
+ $cptContent = ob_get_clean();
117
+ //END the content
118
+ }
119
+ wp_enqueue_script( 'jquery' );
120
+
121
+ $windowCssPath = apply_filters('crop_post_thumbnail_window_css', plugins_url('css/cpt-window.css',dirname(__FILE__)));
122
+ wp_enqueue_style( 'cpt-window',$windowCssPath,array('wp-admin'),CROP_THUMBS_VERSION);
123
+ include_once( dirname(__FILE__).'/../html/template.php' );
124
+ return true;
125
+ }
126
+
127
+
128
+ /**
129
+ * Display the crop editor.
130
+ * @param $_REQUEST['image_id'] - ID of the image to show
131
+ * @param $_REQUEST['viewmode']=='single' - without the back-link
132
+ */
133
+ function byImageId() {
134
+ global $cptSettings,$content_width;
135
+
136
+ //make sure $content_width is out of the way
137
+ $_remember_content_width = $content_width;
138
+ $content_width = null;
139
+
140
+
141
+ $options = $cptSettings->getOptions();
142
+ $this->addDebug('options', print_r($options,true));
143
+ $image_obj = get_post(intval($_REQUEST['image_id']));
144
+
145
+ //$post_id_attached holds the id of the post the image is attached to - can be null/empty
146
+ $post_id_attached = -1;
147
+ if(!empty($image_obj->post_parent)) {
148
+ $post_id_attached=$image_obj->post_parent;
149
+ }
150
+
151
+ //$current_parent_post_type
152
+ $current_parent_post_type = '';
153
+ $current_parent_post_id = -1;
154
+
155
+ if(!empty($_REQUEST['parent_post_id'])) {
156
+ $_tmp = get_post(intval($_REQUEST['parent_post_id']));
157
+ if(!empty($_tmp)) {
158
+ $current_parent_post_type = $_tmp->post_type;
159
+ $current_parent_post_id = $_tmp->ID;
160
+ }
161
+ }
162
+
163
+ $all_image_sizes = $cptSettings->getImageSizes();
164
+ $this->addDebug('all_image_sizes', print_r($all_image_sizes,true));
165
+
166
+ $orig_img = wp_get_attachment_image_src($image_obj->ID, 'full');
167
+ $orig_img['gcd'] = $this->gcd($orig_img[1],$orig_img[2]);
168
+ $orig_img['ratio'] = ($orig_img[1]/$orig_img['gcd']) / ($orig_img[2]/$orig_img['gcd']);
169
+ $orig_img['print_ratio'] = ($orig_img[1]/$orig_img['gcd']).':'.($orig_img[2]/$orig_img['gcd']);
170
+
171
+ $cache_breaker = time();//a additional parameter that will be added to the image-urls to prevent the browser to show a cached image
172
+
173
+ $this->addDebug('img-postmeta',print_r(wp_get_attachment_metadata($image_obj->ID, true),true));
174
+
175
+ //the javascript
176
+ ob_start(); ?>
177
+ <script>
178
+ jQuery(document).ready(function($) {
179
+ cpt_lang = new Object();
180
+ cpt_lang['bug'] = "<?php _e('bug - this case shouldnt be happend',CROP_THUMBS_LANG);?>";
181
+ cpt_lang['warningOriginalToSmall'] = "<?php _e('Warning: the original image is to small to be cropped in good quality with this thumbnail-size.',CROP_THUMBS_LANG);?>";
182
+ cpt_lang['selectOne'] = "<?php _e('First, select one image. Then, click once again.',CROP_THUMBS_LANG);?>";
183
+ cpt_ajax_nonce = "<?php echo wp_create_nonce($cptSettings->getNonceBase()); ?>";
184
+ cpt_debug_js = <?php echo (!empty($options['debug_js'])) ? 'true;' : 'false;'; ?>
185
+ });
186
+ </script>
187
+ <?php
188
+ $cptScript = ob_get_clean();
189
+ //END the javascript
190
+
191
+ /**
192
+ * wether or not to show the "back button"
193
+ */
194
+ $headline = true;
195
+ if(!empty($_REQUEST['viewmode']) && $_REQUEST['viewmode']=='single') {
196
+ $headline = false;
197
+ }
198
+
199
+ //the content
200
+ ob_start();
201
+
202
+ if($this->shouldBeHiddenOnPostType($options,$current_parent_post_type)) : ?>
203
+ <div class="cpt-crop-view">
204
+ <div class="postTypeDisabledMsg"><?php _e('Cropping is disabled for this post-type.',CROP_THUMBS_LANG); ?></div>
205
+ </div>
206
+ <?php else : ?>
207
+
208
+ <div class="cpt-crop-view">
209
+ <?php if($headline) :?><div class="header"><a class="back" href="<?php echo admin_url( 'admin-ajax.php'); ?>?action=croppostthumb_ajax&post_id=<?php echo $current_parent_post_id; ?>"><?php _e('back to image-list',CROP_THUMBS_LANG); ?></a></div><?php endif; ?>
210
+ <div class="waitingWindow hidden"><?php _e('Please wait until the Images are cropped.',CROP_THUMBS_LANG); ?></div>
211
+ <div class="mainWindow">
212
+ <div class="selectionArea cptLeftPane">
213
+ <h3><?php _e('Raw',CROP_THUMBS_LANG); ?>: <?php echo $orig_img[1].' '.__('pixel',CROP_THUMBS_LANG)?> x <?php echo $orig_img[2].' '.__('pixel',CROP_THUMBS_LANG) ?> (<?php echo $orig_img['print_ratio']; ?>)</h3>
214
+ <img src="<?php echo $orig_img[0]?>" data-values='{"id":<?php echo $image_obj->ID; ?>,"parentId":<?php echo $post_id_attached ?>,"width":<?php echo $orig_img[1]?>,"height":<?php echo $orig_img[2] ?>}' />
215
+ <button id="cpt-generate" class="button"><?php _e('save crop',CROP_THUMBS_LANG);?></button>
216
+ <h4><?php _e('Quick-Instructions',CROP_THUMBS_LANG);?></h4>
217
+ <ul class="step-info">
218
+ <li><?php _e('Step 1: Choose an image from the right.',CROP_THUMBS_LANG); ?></li>
219
+ <li><?php _e('Step 2: Use the mouse change the size of the rectangle on the image above.',CROP_THUMBS_LANG); ?></li>
220
+ <li><?php _e('Step 3: Click on "save crop".',CROP_THUMBS_LANG); ?></li>
221
+ </ul>
222
+ </div>
223
+ <div class="cptRightPane">
224
+ <input type="checkbox" name="cpt-same-ratio" value="1" id="cpt-same-ratio" checked="checked" />
225
+ <label for="cpt-same-ratio" class="lbl-cpt-same-ratio"><?php _e('select images with same ratio at once',CROP_THUMBS_LANG); ?></label>
226
+ <button id="cpt-deselect" class="button"><?php _e('deselect all',CROP_THUMBS_LANG); ?></button>
227
+ <ul class="thumbnail-list">
228
+ <?php
229
+ foreach($all_image_sizes as $img_size_name=>$value) :
230
+
231
+ if ($value['height'] == 9999) {
232
+ $value['height'] = 0;
233
+ }
234
+ if ($value['width'] == 9999) {
235
+ $value['width'] = 0;
236
+ }
237
+
238
+ if(!$this->shouldSizeBeHidden($options,$img_size_name,$value,$current_parent_post_type)) :
239
+ $ratio = null; //reset
240
+ $gcd = null; //reset
241
+ $print_ratio = null; //reset
242
+ $print_cropped = ''; //reset
243
+ $crop = 0; //reset
244
+ $special_warning = ''; //reset
245
+
246
+
247
+ /** define ratio **/
248
+ if($value['width'] != 0 && $value['height']!=0) {
249
+ $gcd = $this->gcd($value['width'],$value['height']);//get greatest common divisor
250
+ $ratio = ($value['width']/$gcd) / ($value['height']/$gcd);//get ratio
251
+ $print_ratio = $value['width']/$gcd.':'.$value['height']/$gcd;
252
+ } else {
253
+ //keep ratio same as original image
254
+ $gcd = $orig_img['gcd'];
255
+ $ratio = $orig_img['ratio'];
256
+ $print_ratio = $orig_img['print_ratio'];
257
+ }
258
+
259
+
260
+ if(!empty($value['crop'])) {
261
+ //cropped
262
+ $print_cropped = ' ('.__('cropped',CROP_THUMBS_LANG).')';
263
+ $crop = 1;
264
+ } else {
265
+ //not cropped
266
+ /* -- maybe use this behaviour in a later version --
267
+ $print_cropped = ' ('.__('maximum',CROP_THUMBS_LANG).')';
268
+ $print_ratio = __('free choice',CROP_THUMBS_LANG);
269
+ */
270
+
271
+ $print_cropped = ' ('.__('maximum',CROP_THUMBS_LANG).')';
272
+ $crop = 1;
273
+ //keep ratio same as original image
274
+ $gcd = $orig_img['gcd'];
275
+ $ratio = $orig_img['ratio'];
276
+ $print_ratio = $orig_img['print_ratio'];
277
+ }
278
+
279
+ $print_dimensions = $value['width'].' '.__('pixel',CROP_THUMBS_LANG).' x '.$value['height'].' '.__('pixel',CROP_THUMBS_LANG).$print_cropped;
280
+
281
+ $img_data = wp_get_attachment_image_src($image_obj->ID, $img_size_name);
282
+
283
+
284
+ $_lowResWarning = '';
285
+ if($this->isLowRes($value,$orig_img)) {
286
+ $_lowResWarning = ' <span class="lowResWarning">'.__('Original image to small for good crop-quality!',CROP_THUMBS_LANG).'</span>';
287
+ }
288
+
289
+ ?>
290
+ <li rel="<?php echo $print_ratio; ?>">
291
+ <strong><?php echo $img_size_name.$_lowResWarning; ?></strong><?php echo $special_warning; ?>
292
+ <span class="dimensions"><?php _e('Dimensions:',CROP_THUMBS_LANG) ?> <?php echo $print_dimensions; ?></span>
293
+ <span class="ratio"><?php _e('Ratio:',CROP_THUMBS_LANG) ?> <?php echo $print_ratio; ?></span>
294
+ <img src="<?php echo $img_data[0]?>?<?php echo $cache_breaker ?>" data-values='{"name":"<?php echo $img_size_name; ?>","width":<?php echo $value['width']; ?>,"height":<?php echo $value['height']; ?>,"ratio":<?php echo $ratio ?>,"crop":<?php echo $crop ?>}' />
295
+ </li>
296
+ <?php endif; ?>
297
+ <?php endforeach; ?>
298
+ </ul>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ <?php
303
+ endif;
304
+ $cptContent = ob_get_clean();
305
+ $cptContent.= $this->getDebugOutput($options);
306
+ //END the content
307
+
308
+
309
+ wp_enqueue_script( 'jquery' );
310
+ wp_enqueue_script( 'my_jcrop', plugins_url('js/jcrop/js/jquery.Jcrop.min.js',dirname(__FILE__)), array(), CROP_THUMBS_VERSION);
311
+ wp_enqueue_script( 'json2' );
312
+ wp_enqueue_script( 'cpt-crop', plugins_url('js/cpt-crop.js',dirname(__FILE__)), array('jquery','my_jcrop','json2'), CROP_THUMBS_VERSION);
313
+
314
+ $windowCssPath = apply_filters('crop_post_thumbnail_window_css', plugins_url('css/cpt-window.css',dirname(__FILE__)));
315
+ wp_enqueue_style( 'cpt-window',$windowCssPath,array('wp-admin'),CROP_THUMBS_VERSION);
316
+ wp_enqueue_style( 'my_jcrop', plugins_url('js/jcrop/css/jquery.Jcrop.min.css',dirname(__FILE__)), array(), CROP_THUMBS_VERSION);
317
+
318
+ include_once( dirname(__FILE__).'/../html/template.php' );
319
+
320
+ $content_width = $_remember_content_width;//reset the content-width
321
+ return true;
322
+ }
323
+
324
+ function shouldBeHiddenOnPostType($options,$post_type) {
325
+ if(empty($post_type)) {
326
+ return false;
327
+ }
328
+ if(empty($options['hide_post_type'][$post_type])) {
329
+ return false;
330
+ }
331
+ return true;
332
+ }
333
+
334
+ /**
335
+ * Check wether or not the image_size should be hidden for this post_type
336
+ * @param array options array
337
+ * @param string name of the image-size (i.e. post-thumbnail, ...)
338
+ * @param string name post-type (i.e. post, page, ...)
339
+ * @return boolean true if Image-size should be hidden
340
+ */
341
+ function shouldSizeBeHidden($options, $img_size_name, $img_size, $post_type='') {
342
+ $_return = false;
343
+ if(!empty($post_type)) {
344
+ //we are NOT in the mediathek
345
+
346
+ //-if hide_size
347
+ if(!empty($options['hide_size'][$post_type][$img_size_name])) {
348
+ $_return = true;
349
+ }
350
+
351
+ //if not a crop-size and allow_non_cropped
352
+ if(empty($img_size['crop']) && empty($options['allow_non_cropped'])) {
353
+ $_return = true;
354
+ }
355
+ } else {
356
+ //we are in the mediathek
357
+
358
+ //-if not a crop-size and allow_non_cropped
359
+ if(empty($img_size['crop']) && empty($options['allow_non_cropped'])) {
360
+ $_return = true;
361
+ }
362
+ }
363
+ return $_return;
364
+ }
365
+
366
+
367
+ /**
368
+ * load all image data of that $post_id
369
+ * - adds "is_post_thumbnail" with value true into the entry, if it is the post_thumbnail
370
+ */
371
+ function loadPostIdData($post_id) {
372
+ $args = array(
373
+ 'post_type' => 'attachment',
374
+ 'numberposts' => -1,
375
+ 'post_parent' => intval($post_id)
376
+ );
377
+ $images = get_posts($args);
378
+
379
+ $post_thumbnail_id = get_post_thumbnail_id( $post_id );
380
+ if(!isset($post_thumbnail_id)) {
381
+ $post_thumbnail_id = -1;
382
+ }
383
+
384
+ foreach($images as $key=>$value) {
385
+ $mime = $value->post_mime_type;
386
+ if( $mime !='image/jpeg' AND $mime !='image/png') {
387
+ unset($images[$key]);
388
+ } elseif($value->ID==$post_thumbnail_id) {
389
+ $images[$key]->is_post_thumbnail = true;
390
+ }
391
+ }
392
+ return $images;
393
+ }
394
+
395
+ /**
396
+ * Checks if the thumb-image-dimensions are bigger than the actuall image.
397
+ * @param array thumbnail-data from the add_image_size-funtion (width, height)
398
+ * @param array original image-data-array (url, width, height)
399
+ * @return true if the original is smaller than the thumbnail-size
400
+ */
401
+ function isLowRes($thumb,$orig) {
402
+ if($thumb['width']>$orig[1] || $thumb['height']>$orig[2]) {
403
+ return true;
404
+ }
405
+ return false;
406
+ }
407
+
408
+ function isUserPermitted() {
409
+ $return = false;
410
+ if(current_user_can('upload_files') && current_user_can('edit_pages')) {
411
+ $return = true;
412
+ }
413
+ //TODO maybe add noence (is it needed? there are no file- or db-operations)
414
+ return $return;
415
+ }
416
+
417
+ /**
418
+ * For adding the "thickbox"-style in the mediathek
419
+ */
420
+ function adminHeaderCSS() {
421
+ global $pagenow;
422
+ if ( $pagenow == 'post.php'
423
+ || $pagenow == 'post-new.php'
424
+ || $pagenow == 'page.php'
425
+ || $pagenow == 'page-new.php'
426
+ || $pagenow == 'upload.php') {
427
+ wp_enqueue_style( 'thickbox' );
428
+ }
429
+ }
430
+
431
+
432
+ /**
433
+ * For adding the "crop-thumbnail"-link on posts, pages and the mediathek
434
+ */
435
+ function adminHeaderJS() {
436
+ global $pagenow;
437
+ if ( $pagenow == 'post.php'
438
+ || $pagenow == 'post-new.php'
439
+ || $pagenow == 'page.php'
440
+ || $pagenow == 'page-new.php'
441
+ || $pagenow == 'upload.php') {
442
+
443
+ wp_enqueue_script('thickbox', false, array('jquery','jquery-ui-tabs'));
444
+ add_action('admin_footer',array($this,'cptAddLinksToAdmin'));
445
+ }
446
+ }
447
+
448
+
449
+ /**
450
+ * This is for use inside the plugin only.
451
+ * Removes all other styles and scripts, to make sure the crop-thumbnail is not compromited by other plugins
452
+ */
453
+ function cleanWPHead() {
454
+ global $wp_scripts, $wp_styles;
455
+ $wp_scripts = new WP_Scripts();
456
+ $wp_styles = new WP_Styles();
457
+ remove_all_actions('wp_print_styles');
458
+ remove_all_actions('wp_print_scripts');
459
+ }
460
+
461
+ /**
462
+ * Greatest cummon divisor
463
+ */
464
+ function gcd($a, $b){
465
+ $b = ( $a == 0 )? 0 : $b;
466
+ return ( $a % $b )? $this->gcd($b, abs($a - $b)) : $b;
467
+ }
468
+
469
+
470
+ function addDebug($title, $output) {
471
+ $this->debugOutput.= '---'.$title.'---<br />'.$output.'<br />';
472
+ }
473
+
474
+
475
+ function getDebugOutput($options) {
476
+ if(!empty($options['debug_data'])) {
477
+ return '<div class="cpt-debug closed"><a class="cpt-debug-handle" href="#">show debug</a><div class="content">'.nl2br(str_replace(" ","&nbsp;&nbsp;",$this->debugOutput)).'</div></div>';
478
+ }
479
+ return '';
480
+ }
481
+
482
+
483
+ /**
484
+ * adds the links into post-types and the media-library
485
+ */
486
+ function cptAddLinksToAdmin() {
487
+ ?>
488
+ <script type="text/javascript">
489
+ jQuery(document).ready(function($) {
490
+ var boxViewportHeight = $(window).height() - 100;
491
+ //add link on posts and pages
492
+ if ($('body.post-php, body.page-php, body.page-new.php, body.post-new-php').length > 0) {
493
+ var post_id_hidden = $('form#post #post_ID');
494
+ if (post_id_hidden) {
495
+
496
+ post_id_hidden = parseInt(post_id_hidden.val());
497
+
498
+ /** add link on top of editor **/
499
+ $('#wp-content-media-buttons').append('<a style="margin:0 2em;" class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;post_id=' + post_id_hidden + '&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Thumbnails',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Thumbnails',CROP_THUMBS_LANG); ?></a>');
500
+
501
+
502
+ /** add link to featured image box **/
503
+ var featuredImageLink = $('<a class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;image_by_post_id=' + post_id_hidden + '&amp;viewmode=single&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Featured Image',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Featured Image',CROP_THUMBS_LANG); ?></a>')
504
+ .css({'margin':'5px', 'padding':'5px','display':'inline-block','line-height':'1'})
505
+ .addClass('button');
506
+ $('#postimagediv .inside').after(featuredImageLink);
507
+ }
508
+ }
509
+
510
+ /** add link on mediathek **/
511
+ if ($('body.upload-php').length > 0) {
512
+ $('#the-list tr').each(function() {
513
+ if ($(this).find('td.media-icon img').attr('src').lastIndexOf("/wp-includes/images/") == -1) {
514
+ var post_id = parseInt($(this).attr('id').substr(5));
515
+ var last_span = $(this).find('.column-title .row-actions span:last-child');
516
+ last_span.append(' | ');
517
+ last_span.parent().append('<a class="thickbox" href="' + ajaxurl + '?action=croppostthumb_ajax&amp;image_id=' + post_id + '&amp;viewmode=single&amp;TB_iframe=1&amp;width=800&amp;height=' + boxViewportHeight + '" title="<?php esc_attr_e('Crop Thumbnail',CROP_THUMBS_LANG) ?>"><?php esc_html_e('Crop Thumbnail',CROP_THUMBS_LANG); ?></a>')
518
+ }
519
+ });
520
+ }
521
+ });
522
+ </script>
523
+ <?php
524
+ }
525
+ }
526
+
527
+
528
+
529
+ $cpte = new CropPostThumbnailsEditor();
530
  ?>
functions/save.php CHANGED
@@ -1,255 +1,255 @@
1
- <?php
2
- $cptSave = new CptSaveThumbnail();
3
- add_action( 'wp_ajax_cptSaveThumbnail', array($cptSave, 'saveThumbnail') );
4
-
5
- class CptSaveThumbnail {
6
-
7
- private $debug = array();
8
-
9
- /**
10
- * Handle-function called via ajax request.
11
- * Check and crop multiple Images. Update with wp_update_attachment_metadata if needed.
12
- * Input parameters:
13
- * * $_REQUEST['selection'] - json-object - data of the selection/crop
14
- * * $_REQUEST['raw_values'] - json-object - data of the original image
15
- * * $_REQUEST['active_values'] - json-array - array with data of the images to crop
16
- * The main code is wraped via try-catch - the errorMessage will send back to JavaScript for displaying in an alert-box.
17
- * Called die() at the end.
18
- */
19
- function saveThumbnail() {
20
- global $cptSettings;
21
- $json_return = array();
22
-
23
- try {
24
- /** get data **/
25
- $upload_dir = wp_upload_dir();
26
- $tmp_dir = $upload_dir['basedir']."/tmp/";
27
- $options = $cptSettings->getOptions();
28
- //from $_REQUEST
29
- $selection = json_decode(stripcslashes($_REQUEST['selection']));
30
- $sourceImgData = json_decode(stripcslashes($_REQUEST['raw_values']));
31
- $targetImgData = json_decode(stripcslashes($_REQUEST['active_values']));
32
-
33
- //from DB
34
- $dbImageSizes = $cptSettings->getImageSizes();
35
-
36
- $obj = get_post($sourceImgData->id);
37
- $sourceImgPath = get_attached_file( $obj->ID );
38
- $post_metadata = wp_get_attachment_metadata($obj->ID, true);//get the attachement metadata of the post
39
-
40
- $this->validation($selection,$obj,$sourceImgPath,$post_metadata);
41
-
42
-
43
- #$debug.= "\nselection\n".print_r($selection,true);
44
- #$debug.= "\ntargetImgData\n".print_r($sourceImgData,true);
45
- #$debug.= "\ntargetImgData\n".print_r($targetImgData,true);
46
- #$debug.= "\nimageObject\n".print_r($obj,true);
47
- #$debug.= "\nsource:".$sourceImgPath."\n";
48
-
49
- /**
50
- * will be true if the image format issnt in the attachements metadata,
51
- * and wordpress dont know about the image-file
52
- */
53
- $_changed_image_format = false;
54
- $_processing_error = array();
55
- foreach($targetImgData as $_imageSize) {
56
- $this->addDebug('submitted image-data');
57
- $this->addDebug(print_r($_imageSize,true));
58
- $_delete_old_file = '';
59
- if(!$this->isImageSizeValid($_imageSize,$dbImageSizes)) {
60
- $this->addDebug("Image Size not valid.");
61
- continue;
62
- }
63
- if(empty($post_metadata['sizes'][$_imageSize->name])) {
64
- $_changed_image_format = true;
65
- } else {
66
- //the old size hasent got the right image-size/image-ratio --> delete it or nobody will ever delete it correct
67
- if($post_metadata['sizes'][$_imageSize->name]['width'] != intval($_imageSize->width)
68
- || $post_metadata['sizes'][$_imageSize->name]['height'] != intval($_imageSize->height) ) {
69
-
70
- $_delete_old_file = $post_metadata['sizes'][$_imageSize->name]['file'];
71
- $_changed_image_format = true;
72
- }
73
- }
74
-
75
-
76
-
77
- $_filepath = $this->generateFilename($sourceImgPath, $_imageSize->width, $_imageSize->height);
78
- $_filepath_info = pathinfo($_filepath);
79
- $_tmp_filepath = $tmp_dir.$_filepath_info['basename'];
80
- $this->addDebug("filename:".$_filepath);
81
-
82
-
83
- $crop_width = $_imageSize->width;
84
- $crop_height = $_imageSize->height;
85
- if(!$_imageSize->crop || $_imageSize->width==0 || $_imageSize->height==0) {
86
- //handle images with no crop
87
- $crop_width = $selection->x2 - $selection->x;
88
- $crop_height = $selection->y2 - $selection->y;
89
- }
90
-
91
- $result = wp_crop_image( // * @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
92
- intval($sourceImgData->id), // * @param string|int $src The source file or Attachment ID.
93
- $selection->x, // * @param int $src_x The start x position to crop from.
94
- $selection->y, // * @param int $src_y The start y position to crop from.
95
- $selection->x2 - $selection->x, // * @param int $src_w The width to crop.
96
- $selection->y2 - $selection->y, // * @param int $src_h The height to crop.
97
- $crop_width, // * @param int $dst_w The destination width.
98
- $crop_height, // * @param int $dst_h The destination height.
99
- false, // * @param int $src_abs Optional. If the source crop points are absolute.
100
- $_tmp_filepath // * @param string $dst_file Optional. The destination file to write to.
101
- );
102
-
103
- $_error = false;
104
- if(empty($result)) {
105
- $_processing_error[] = sprintf(__('Cant generate filesize "%s".',CROP_THUMBS_LANG),$_imageSize->name);
106
- $_error = true;
107
- } else {
108
- if(!empty($_delete_old_file)) {
109
- @unlink($_filepath_info['dirname'].'/'.$_delete_old_file);
110
- }
111
- if(!@copy($result,$_filepath)) {
112
- $_processing_error[] = sprintf(__('Cant copy temporary file to media-library.',CROP_THUMBS_LANG));
113
- $_error = true;
114
- }
115
- if(!@unlink($result)) {
116
- $_processing_error[] = sprintf(__('Cant delete temporary file.',CROP_THUMBS_LANG));
117
- $_error = true;
118
- }
119
- }
120
-
121
- if(!$_error) {
122
- //update metadata --> otherwise new sizes will not be updated
123
- $_new_meta = array(
124
- 'file'=>$_filepath_info['basename'],
125
- 'width'=>intval($crop_width),
126
- 'height'=>intval($crop_height));
127
- if(!empty($dbImageSizes[$_imageSize->name]['crop'])) {
128
- $_new_meta['crop'] = $dbImageSizes[$_imageSize->name]['crop'];
129
- }
130
- $post_metadata['sizes'][$_imageSize->name] = $_new_meta;
131
- } else {
132
- $this->addDebug('error on '.$_filepath_info['basename']);
133
- }
134
- }
135
-
136
- //we have to update the posts metadate
137
- //otherwise new sizes will not be updated
138
- wp_update_attachment_metadata( $obj->ID, $post_metadata);
139
-
140
- //generate result;
141
- $json_return['debug'] = $this->getDebugOutput($options);
142
- if(!empty($_processing_error)) {
143
- //one or more errors happend when generating thumbnails
144
- $json_return['processingErrors'] = implode("\n",$_processing_error);
145
- }
146
- if($_changed_image_format) {
147
- //there was a change in the image-formats
148
- $json_return['changed_image_format'] = true;
149
- }
150
- $json_return['success'] = time();//time for cache-breaker
151
- echo json_encode($json_return);
152
- } catch (Exception $e) {
153
- $json_return['debug'] = $this->getDebugOutput($options);
154
- $json_return['error'] = $e->getMessage();
155
- echo json_encode($json_return);
156
- }
157
- die();
158
- }
159
-
160
- private function addDebug($text) {
161
- $this->debug[] = $text;
162
- }
163
-
164
- private function getDebugOutput($options) {
165
- if(!empty($this->debug)) {
166
- return join("\n",$this->debug);
167
- }
168
- return '';
169
- }
170
-
171
- /**
172
- * @param object data of the new ImageSize the user want to crop
173
- * @param array all available ImageSizes
174
- * @return boolean true if the newImageSize is in the list of ImageSizes and dimensions are correct
175
- */
176
- function isImageSizeValid(&$submitted,$dbData) {
177
- if(empty($submitted->name)) {
178
- return false;
179
- }
180
- if(empty($dbData[$submitted->name])) {
181
- return false;
182
- }
183
-
184
- //restore the default data just to make sure nothing is compromited
185
- $submitted->crop = empty($dbData[$submitted->name]['crop']) ? 0 : 1;
186
- $submitted->width = $dbData[$submitted->name]['width'];
187
- $submitted->height = $dbData[$submitted->name]['height'];
188
- //eventually we want to test some more later
189
- return true;
190
- }
191
-
192
- /**
193
- * some basic validations and value transformations
194
- * @param array the user submitted selection
195
- * @param object the loaded image-object loaded by $sourceImgData->id
196
- * @param string the server-path to the source-image
197
- * @param object metadata of the image-attachement
198
- * @throw Exception if the security validation fails
199
- */
200
- function validation($selection,$obj,$sourceImgPath,$post_metadata) {
201
- global $cptSettings;
202
- if(!check_ajax_referer($cptSettings->getNonceBase(),'_ajax_nonce',false)) {
203
- throw new Exception(__("ERROR: Security Check failed (maybe a timeout - please try again).",CROP_THUMBS_LANG), 1);
204
- }
205
-
206
- if(!isset($selection->x) || !isset($selection->y) || !isset($selection->x2) || !isset($selection->y2)) {
207
- throw new Exception(__('ERROR: Submitted data are not complete.',CROP_THUMBS_LANG), 1);
208
- }
209
- $selection->x = intval($selection->x);
210
- $selection->y = intval($selection->y);
211
- $selection->x2 = intval($selection->x2);
212
- $selection->y2 = intval($selection->y2);
213
-
214
- if($selection->x < 0 || $selection->y < 0) {
215
- throw new Exception(__('A cropping with this dimensions on these Image ist not possible.',CROP_THUMBS_LANG), 1);
216
- }
217
-
218
- /**
219
- $_test = 20948;
220
- $obj = get_post($_test);
221
- $sourceImgPath = get_attached_file($_test);
222
- $post_metadata = wp_get_attachment_metadata($_test, true);//get the attachement metadata of the post
223
- */
224
-
225
- if(empty($obj)) {
226
- throw new Exception(__('ERROR: Can`t find original Image in Database!',CROP_THUMBS_LANG), 1);
227
- }
228
- if(empty($sourceImgPath)) {
229
- throw new Exception(__('ERROR: Can`t find original Imagefile!',CROP_THUMBS_LANG), 1);
230
- }
231
- if(empty($post_metadata)) {
232
- throw new Exception(__('ERROR: Can`t find original Image-Metadata!',CROP_THUMBS_LANG), 1);
233
- }
234
- }
235
-
236
- /**
237
- * Generate the Filename (and path) of the thumbnail based on width and height the same way as wordpress do.
238
- * @see generate_filename in wp-includes/class-wp-image-editor.php
239
- * @param string Path to the original (full-size) file.
240
- * @param int width of the new image
241
- * @param int height of the new image
242
- * @return string path to the new image
243
- */
244
- function generateFilename( $file, $w, $h ){
245
- $info = pathinfo($file);
246
- $dir = $info['dirname'];
247
- $ext = $info['extension'];
248
- $name = wp_basename($file, ".$ext");
249
- $suffix = "{$w}x{$h}";
250
- $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
251
-
252
- return $destfilename;
253
- }
254
- }
255
  ?>
1
+ <?php
2
+ $cptSave = new CptSaveThumbnail();
3
+ add_action( 'wp_ajax_cptSaveThumbnail', array($cptSave, 'saveThumbnail') );
4
+
5
+ class CptSaveThumbnail {
6
+
7
+ private $debug = array();
8
+
9
+ /**
10
+ * Handle-function called via ajax request.
11
+ * Check and crop multiple Images. Update with wp_update_attachment_metadata if needed.
12
+ * Input parameters:
13
+ * * $_REQUEST['selection'] - json-object - data of the selection/crop
14
+ * * $_REQUEST['raw_values'] - json-object - data of the original image
15
+ * * $_REQUEST['active_values'] - json-array - array with data of the images to crop
16
+ * The main code is wraped via try-catch - the errorMessage will send back to JavaScript for displaying in an alert-box.
17
+ * Called die() at the end.
18
+ */
19
+ function saveThumbnail() {
20
+ global $cptSettings;
21
+ $json_return = array();
22
+
23
+ try {
24
+ /** get data **/
25
+ $upload_dir = wp_upload_dir();
26
+ $tmp_dir = $upload_dir['basedir']."/tmp/";
27
+ $options = $cptSettings->getOptions();
28
+ //from $_REQUEST
29
+ $selection = json_decode(stripcslashes($_REQUEST['selection']));
30
+ $sourceImgData = json_decode(stripcslashes($_REQUEST['raw_values']));
31
+ $targetImgData = json_decode(stripcslashes($_REQUEST['active_values']));
32
+
33
+ //from DB
34
+ $dbImageSizes = $cptSettings->getImageSizes();
35
+
36
+ $obj = get_post($sourceImgData->id);
37
+ $sourceImgPath = get_attached_file( $obj->ID );
38
+ $post_metadata = wp_get_attachment_metadata($obj->ID, true);//get the attachement metadata of the post
39
+
40
+ $this->validation($selection,$obj,$sourceImgPath,$post_metadata);
41
+
42
+
43
+ #$debug.= "\nselection\n".print_r($selection,true);
44
+ #$debug.= "\ntargetImgData\n".print_r($sourceImgData,true);
45
+ #$debug.= "\ntargetImgData\n".print_r($targetImgData,true);
46
+ #$debug.= "\nimageObject\n".print_r($obj,true);
47
+ #$debug.= "\nsource:".$sourceImgPath."\n";
48
+
49
+ /**
50
+ * will be true if the image format issnt in the attachements metadata,
51
+ * and wordpress dont know about the image-file
52
+ */
53
+ $_changed_image_format = false;
54
+ $_processing_error = array();
55
+ foreach($targetImgData as $_imageSize) {
56
+ $this->addDebug('submitted image-data');
57
+ $this->addDebug(print_r($_imageSize,true));
58
+ $_delete_old_file = '';
59
+ if(!$this->isImageSizeValid($_imageSize,$dbImageSizes)) {
60
+ $this->addDebug("Image Size not valid.");
61
+ continue;
62
+ }
63
+ if(empty($post_metadata['sizes'][$_imageSize->name])) {
64
+ $_changed_image_format = true;
65
+ } else {
66
+ //the old size hasent got the right image-size/image-ratio --> delete it or nobody will ever delete it correct
67
+ if($post_metadata['sizes'][$_imageSize->name]['width'] != intval($_imageSize->width)
68
+ || $post_metadata['sizes'][$_imageSize->name]['height'] != intval($_imageSize->height) ) {
69
+
70
+ $_delete_old_file = $post_metadata['sizes'][$_imageSize->name]['file'];
71
+ $_changed_image_format = true;
72
+ }
73
+ }
74
+
75
+
76
+
77
+ $_filepath = $this->generateFilename($sourceImgPath, $_imageSize->width, $_imageSize->height);
78
+ $_filepath_info = pathinfo($_filepath);
79
+ $_tmp_filepath = $tmp_dir.$_filepath_info['basename'];
80
+ $this->addDebug("filename:".$_filepath);
81
+
82
+
83
+ $crop_width = $_imageSize->width;
84
+ $crop_height = $_imageSize->height;
85
+ if(!$_imageSize->crop || $_imageSize->width==0 || $_imageSize->height==0 || $_imageSize->width==9999 || $_imageSize->height==9999) {
86
+ //handle images with soft-crop width/height value and crop set to "true"
87
+ $crop_width = $selection->x2 - $selection->x;
88
+ $crop_height = $selection->y2 - $selection->y;
89
+ }
90
+
91
+ $result = wp_crop_image( // * @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
92
+ intval($sourceImgData->id), // * @param string|int $src The source file or Attachment ID.
93
+ $selection->x, // * @param int $src_x The start x position to crop from.
94
+ $selection->y, // * @param int $src_y The start y position to crop from.
95
+ $selection->x2 - $selection->x, // * @param int $src_w The width to crop.
96
+ $selection->y2 - $selection->y, // * @param int $src_h The height to crop.
97
+ $crop_width, // * @param int $dst_w The destination width.
98
+ $crop_height, // * @param int $dst_h The destination height.
99
+ false, // * @param int $src_abs Optional. If the source crop points are absolute.
100
+ $_tmp_filepath // * @param string $dst_file Optional. The destination file to write to.
101
+ );
102
+
103
+ $_error = false;
104
+ if(empty($result)) {
105
+ $_processing_error[] = sprintf(__('Cant generate filesize "%s".',CROP_THUMBS_LANG),$_imageSize->name);
106
+ $_error = true;
107
+ } else {
108
+ if(!empty($_delete_old_file)) {
109
+ @unlink($_filepath_info['dirname'].'/'.$_delete_old_file);
110
+ }
111
+ if(!@copy($result,$_filepath)) {
112
+ $_processing_error[] = sprintf(__('Cant copy temporary file to media-library.',CROP_THUMBS_LANG));
113
+ $_error = true;
114
+ }
115
+ if(!@unlink($result)) {
116
+ $_processing_error[] = sprintf(__('Cant delete temporary file.',CROP_THUMBS_LANG));
117
+ $_error = true;
118
+ }
119
+ }
120
+
121
+ if(!$_error) {
122
+ //update metadata --> otherwise new sizes will not be updated
123
+ $_new_meta = array(
124
+ 'file'=>$_filepath_info['basename'],
125
+ 'width'=>intval($crop_width),
126
+ 'height'=>intval($crop_height));
127
+ if(!empty($dbImageSizes[$_imageSize->name]['crop'])) {
128
+ $_new_meta['crop'] = $dbImageSizes[$_imageSize->name]['crop'];
129
+ }
130
+ $post_metadata['sizes'][$_imageSize->name] = $_new_meta;
131
+ } else {
132
+ $this->addDebug('error on '.$_filepath_info['basename']);
133
+ }
134
+ }
135
+
136
+ //we have to update the posts metadate
137
+ //otherwise new sizes will not be updated
138
+ wp_update_attachment_metadata( $obj->ID, $post_metadata);
139
+
140
+ //generate result;
141
+ $json_return['debug'] = $this->getDebugOutput($options);
142
+ if(!empty($_processing_error)) {
143
+ //one or more errors happend when generating thumbnails
144
+ $json_return['processingErrors'] = implode("\n",$_processing_error);
145
+ }
146
+ if($_changed_image_format) {
147
+ //there was a change in the image-formats
148
+ $json_return['changed_image_format'] = true;
149
+ }
150
+ $json_return['success'] = time();//time for cache-breaker
151
+ echo json_encode($json_return);
152
+ } catch (Exception $e) {
153
+ $json_return['debug'] = $this->getDebugOutput($options);
154
+ $json_return['error'] = $e->getMessage();
155
+ echo json_encode($json_return);
156
+ }
157
+ die();
158
+ }
159
+
160
+ private function addDebug($text) {
161
+ $this->debug[] = $text;
162
+ }
163
+
164
+ private function getDebugOutput($options) {
165
+ if(!empty($this->debug)) {
166
+ return join("\n",$this->debug);
167
+ }
168
+ return '';
169
+ }
170
+
171
+ /**
172
+ * @param object data of the new ImageSize the user want to crop
173
+ * @param array all available ImageSizes
174
+ * @return boolean true if the newImageSize is in the list of ImageSizes and dimensions are correct
175
+ */
176
+ function isImageSizeValid(&$submitted,$dbData) {
177
+ if(empty($submitted->name)) {
178
+ return false;
179
+ }
180
+ if(empty($dbData[$submitted->name])) {
181
+ return false;
182
+ }
183
+
184
+ //restore the default data just to make sure nothing is compromited
185
+ $submitted->crop = empty($dbData[$submitted->name]['crop']) ? 0 : 1;
186
+ $submitted->width = $dbData[$submitted->name]['width'];
187
+ $submitted->height = $dbData[$submitted->name]['height'];
188
+ //eventually we want to test some more later
189
+ return true;
190
+ }
191
+
192
+ /**
193
+ * some basic validations and value transformations
194
+ * @param array the user submitted selection
195
+ * @param object the loaded image-object loaded by $sourceImgData->id
196
+ * @param string the server-path to the source-image
197
+ * @param object metadata of the image-attachement
198
+ * @throw Exception if the security validation fails
199
+ */
200
+ function validation($selection,$obj,$sourceImgPath,$post_metadata) {
201
+ global $cptSettings;
202
+ if(!check_ajax_referer($cptSettings->getNonceBase(),'_ajax_nonce',false)) {
203
+ throw new Exception(__("ERROR: Security Check failed (maybe a timeout - please try again).",CROP_THUMBS_LANG), 1);
204
+ }
205
+
206
+ if(!isset($selection->x) || !isset($selection->y) || !isset($selection->x2) || !isset($selection->y2)) {
207
+ throw new Exception(__('ERROR: Submitted data are not complete.',CROP_THUMBS_LANG), 1);
208
+ }
209
+ $selection->x = intval($selection->x);
210
+ $selection->y = intval($selection->y);
211
+ $selection->x2 = intval($selection->x2);
212
+ $selection->y2 = intval($selection->y2);
213
+
214
+ if($selection->x < 0 || $selection->y < 0) {
215
+ throw new Exception(__('A cropping with this dimensions on these Image ist not possible.',CROP_THUMBS_LANG), 1);
216
+ }
217
+
218
+ /**
219
+ $_test = 20948;
220
+ $obj = get_post($_test);
221
+ $sourceImgPath = get_attached_file($_test);
222
+ $post_metadata = wp_get_attachment_metadata($_test, true);//get the attachement metadata of the post
223
+ */
224
+
225
+ if(empty($obj)) {
226
+ throw new Exception(__('ERROR: Can`t find original Image in Database!',CROP_THUMBS_LANG), 1);
227
+ }
228
+ if(empty($sourceImgPath)) {
229
+ throw new Exception(__('ERROR: Can`t find original Imagefile!',CROP_THUMBS_LANG), 1);
230
+ }
231
+ if(empty($post_metadata)) {
232
+ throw new Exception(__('ERROR: Can`t find original Image-Metadata!',CROP_THUMBS_LANG), 1);
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Generate the Filename (and path) of the thumbnail based on width and height the same way as wordpress do.
238
+ * @see generate_filename in wp-includes/class-wp-image-editor.php
239
+ * @param string Path to the original (full-size) file.
240
+ * @param int width of the new image
241
+ * @param int height of the new image
242
+ * @return string path to the new image
243
+ */
244
+ function generateFilename( $file, $w, $h ){
245
+ $info = pathinfo($file);
246
+ $dir = $info['dirname'];
247
+ $ext = $info['extension'];
248
+ $name = wp_basename($file, ".$ext");
249
+ $suffix = "{$w}x{$h}";
250
+ $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
251
+
252
+ return $destfilename;
253
+ }
254
+ }
255
  ?>
functions/settings.php CHANGED
@@ -1,285 +1,285 @@
1
- <?php
2
- class CropThumbnailsSettings {
3
- private $uniqeSettingsId = 'cpt-settings';
4
- private $optionsKey = 'crop-post-thumbs';
5
- private $cssPrefix = 'cpt_settings_';
6
- private $standardSizes = array('thumbnail','medium','large');
7
-
8
- function __construct() {
9
- add_action('admin_menu', array($this,'addOptionsPage'));
10
- if(is_admin()) {
11
- add_filter('plugin_action_links', array($this,'addSettingsLinkToPluginPage'), 10, 2);
12
- add_action('admin_head', array($this,'optionsPageStyle'));
13
- }
14
- }
15
-
16
- function optionsPageStyle() {
17
- if(!empty($_REQUEST['page']) && $_REQUEST['page']=='page-cpt') {
18
- wp_enqueue_style('crop-thumbnails-options-style',plugins_url('css/options.css',dirname(__FILE__)));
19
- }
20
- }
21
-
22
- function addSettingsLinkToPluginPage($links, $file) {
23
- if ($file === 'crop-thumbnails/crop-thumbnails.php'){
24
- $settings_link = '<a href="options-general.php?page=page-cpt" title="">'.__('Settings',CROP_THUMBS_LANG).'</a>';
25
- array_unshift( $links, $settings_link );
26
- }
27
- return $links;
28
- }
29
-
30
- function addOptionsPage() {
31
- add_options_page(__('Crop Post Thumbnail Page',CROP_THUMBS_LANG), 'Crop-Thumbnails', 'manage_options', 'page-cpt', array($this,'optionsPage'));
32
- add_action('admin_init', array($this,'settingsInitialisation'));
33
- }
34
-
35
- function optionsPage() { ?>
36
- <div class="wrap">
37
- <div id="icon-options-general" class="icon32"><br /></div>
38
- <h2>Crop-Thumbnails <?php esc_attr_e('Settings',CROP_THUMBS_LANG); ?></h2>
39
- <form action="options.php" method="post">
40
- <?php settings_fields($this->uniqeSettingsId); ?>
41
- <?php do_settings_sections('page1'); ?>
42
-
43
- <div class="<?php echo $this->cssPrefix ?>submit">
44
- <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes',CROP_THUMBS_LANG); ?>" class="button-primary" />
45
- </div>
46
- </form>
47
-
48
- <div class="<?php echo $this->cssPrefix; ?>paypal">
49
- <h3><?php _e('Support the plugin-author',CROP_THUMBS_LANG) ?></h3>
50
- <p><?php _e('You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!',CROP_THUMBS_LANG); ?></p>
51
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
52
- <input type="hidden" name="cmd" value="_donations">
53
- <input type="hidden" name="business" value="volkmar.kantor@gmx.de">
54
- <input type="hidden" name="lc" value="DE">
55
- <input type="hidden" name="item_name" value="Volkmar Kantor - totalmedial.de">
56
- <input type="hidden" name="item_number" value="crop-thumbnails">
57
- <input type="hidden" name="no_note" value="0">
58
- <input type="hidden" name="currency_code" value="EUR">
59
- <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
60
- <input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">
61
- <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
62
- </form>
63
- </div>
64
- </div>
65
- <?php
66
- }
67
-
68
- function settingsInitialisation(){
69
- register_setting( $this->uniqeSettingsId, $this->optionsKey, array($this,'validateSettings') );
70
-
71
- $_sectionID = 'choose_sizes_section';
72
- add_settings_section($_sectionID, __('Sizes and Posttypes',CROP_THUMBS_LANG), array($this,'sectionDescriptionChooseSizes'), 'page1');
73
- add_settings_field('sizes', __('Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries.',CROP_THUMBS_LANG), array($this,'callback_choose_size'), 'page1', $_sectionID);
74
- /*
75
- $_sectionID = 'experimental';
76
- add_settings_section($_sectionID, __('Experimental Settings',CROP_THUMBS_LANG), array($this,'emptySectionDescription'), 'page1');
77
- $_tmpID = 'allow_non_cropped';
78
- add_settings_field($_tmpID, __('Allow non cropped image-sizes.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
79
- */
80
- $_sectionID = 'developer';
81
- add_settings_section($_sectionID, __('Developer Settings',CROP_THUMBS_LANG), array($this,'emptySectionDescription'), 'page1');
82
- $_tmpID = 'debug_js';
83
- add_settings_field($_tmpID, __('Enable JS-Debug.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
84
- $_tmpID = 'debug_data';
85
- add_settings_field($_tmpID, __('Enable Data-Debug.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
86
- }
87
-
88
- function sectionDescriptionChooseSizes() {?>
89
- <p>
90
- <?php _e('Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface.',CROP_THUMBS_LANG) ?>
91
- <br /><strong><?php _e('Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden.',CROP_THUMBS_LANG); ?></strong>
92
- </p>
93
- <?php
94
- }
95
-
96
- function emptySectionDescription() {/*empty*/ }
97
-
98
- function callback_choose_size() {
99
- //get all the data
100
- $options = get_option($this->optionsKey);
101
- #echo '<pre>'.print_r($options,true).'</pre>';
102
- $post_types = $this->getPostTypes();
103
- $image_sizes = $this->getImageSizes();
104
-
105
- //output
106
- echo '<ul>';
107
- foreach($post_types as $post_type=>$value) { ?>
108
- <li>
109
- <label for="<?php echo $this->cssPrefix.$post_type; ?>">
110
- <input id="<?php echo $this->cssPrefix.$post_type;?>" type="checkbox" name="<?php echo $this->optionsKey; ?>[hide_post_type][<?php echo $post_type;?>]" value="1" <?php checked(isset($options['hide_post_type'][$post_type]),true); ?> />
111
- <strong><?php echo $value->labels->name; ?></strong>
112
- </label>
113
- <ul style="margin:1em;">
114
- <?php
115
-
116
- foreach($image_sizes as $thumb_name => $data) :
117
- $_checked = false;
118
- if(!empty($options['hide_size']) && is_array($options['hide_size']) && !empty($options['hide_size'][$post_type][$thumb_name])) {
119
- $_checked = true;
120
- }
121
- if($data['crop']=='1') :
122
- ?>
123
- <li>
124
- <label for="<?php echo $this->cssPrefix.$post_type;?>-<?php echo $thumb_name;?>">
125
- <input id="<?php echo $this->cssPrefix.$post_type;?>-<?php echo $thumb_name;?>" type="checkbox" name="<?php echo $this->optionsKey; ?>[hide_size][<?php echo $post_type; ?>][<?php echo $thumb_name; ?>]" value="1" <?php echo checked($_checked); ?> />
126
- <?php echo $thumb_name;?> - <?php echo $data['width'];?>x<?php echo $data['height'];?> <?php /* echo ($data['crop'] == '1' ? '(cropped)' : '') */?>
127
- </label>
128
- </li>
129
- <?php endif; ?>
130
- <?php endforeach ?>
131
- </ul>
132
- <hr />
133
- </li>
134
- <?php
135
- }
136
- echo '</ul>';
137
- }
138
-
139
- function callback_allow_non_cropped() {
140
- $options = get_option($this->optionsKey);
141
- $_id = 'allow_non_cropped';
142
- if(empty($options[$_id])) { $options[$_id] = ''; }
143
- echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false) . ' />';
144
- ?>
145
- <div class="info">
146
- <?php _e('ATTENTION: be aware that you can break things, when you activate this. When activated your are able to cut those images to a spezific dimension that are not cropped. The name of the image will not change. You should be extra carefull when:',CROP_THUMBS_LANG) ?>
147
- <ul>
148
- <li><?php _e('you had inserted the image before on any page or post. (There may be height and width stored directly in the page-content.)',CROP_THUMBS_LANG); ?></li>
149
- <li><?php _e('you use a plugin that expect the original image size. (The original image-size is also "stored" in the filename.)',CROP_THUMBS_LANG); ?></li>
150
- </ul>
151
- <p><?php _e('The "full" image-size will never be cropped, otherwise you are not able to restore any image-size.',CROP_THUMBS_LANG); ?></p>
152
- </div>
153
- <?php
154
- }
155
-
156
- function callback_debug_js() {
157
- $options = get_option($this->optionsKey);
158
- $_id = 'debug_js';
159
- if(empty($options[$_id])) { $options[$_id] = ''; }
160
- echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false) . ' />';
161
- }
162
-
163
- function callback_debug_data() {
164
- $options = get_option($this->optionsKey);
165
- $_id = 'debug_data';
166
- if(empty($options[$_id])) { $options[$_id] = ''; }
167
- echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false ) . ' />';
168
- }
169
-
170
- function validateSettings($input) {
171
- $sizes = $this->getImageSizes();
172
-
173
- $post_types = $this->getPostTypes();
174
-
175
- $storeInDb = array();
176
- //check input[hide_post_type] --> are the post_types real there
177
- if(!empty($input['hide_post_type'])) {
178
- foreach($input['hide_post_type'] as $_post_type_name=>$value) {
179
- if(isset($post_types[$_post_type_name])) {
180
- $storeInDb['hide_post_type'][$_post_type_name] = '1';
181
- }
182
- }
183
- }
184
-
185
-
186
- //check $input[sizes] --> are post_types correct, are sizes real there
187
- if(!empty($input['hide_size'])) {
188
- foreach($input['hide_size'] as $_post_type_name=>$size_type) {
189
- if(isset($post_types[$_post_type_name])) {
190
- foreach($size_type as $_size_name=>$value) {
191
- if(isset($sizes[$_size_name])) {
192
- $storeInDb['hide_size'][$_post_type_name][$_size_name] = '1';
193
- }
194
- }
195
- }
196
- }
197
- }
198
-
199
- /* Experimental Section */
200
- $_tmpID = 'allow_non_cropped';
201
- if(!empty($input[$_tmpID])) {
202
- $storeInDb[$_tmpID] = 1;
203
- }
204
-
205
- /* Advanced Section */
206
- $_tmpID = 'debug_js';
207
- if(!empty($input[$_tmpID])) {
208
- $storeInDb[$_tmpID] = 1;
209
- }
210
-
211
- $_tmpID = 'debug_data';
212
- if(!empty($input[$_tmpID])) {
213
- $storeInDb[$_tmpID] = 1;
214
- }
215
-
216
- return $storeInDb;
217
- }
218
-
219
- /* helper functions **********************************************************************************************/
220
-
221
-
222
- /**
223
- * get the post types and delete some prebuild post types that we dont need
224
- */
225
- function getPostTypes() {
226
- $post_types = get_post_types(array(),'objects');
227
- unset($post_types['nav_menu_item']);
228
- unset($post_types['revision']);
229
- unset($post_types['attachment']);
230
- return $post_types;
231
- }
232
-
233
-
234
- /**
235
- * Creates an array of all image sizes:
236
- * array[sizename][height]
237
- * array[sizename][width]
238
- * array[sizename][crop] = boolean
239
- *
240
- * Thanks to the ajax_thumbnail_rebuild plugin and post-thumbnail-editor
241
- */
242
- function getImageSizes() {
243
- global $_wp_additional_image_sizes;//array with the available image sizes
244
- $tmp_sizes = get_intermediate_image_sizes();
245
- $sizes = array();
246
- foreach ($tmp_sizes as $s){
247
- //width
248
- if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {// theme-added size
249
- $width = intval( $_wp_additional_image_sizes[$s]['width'] );
250
- } else { // default sizes set in options
251
- $width = get_option( "{$s}_size_w" );
252
- }
253
- //height
254
- if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) {// theme-added size
255
- $height = intval( $_wp_additional_image_sizes[$s]['height'] );
256
- } else { // default sizes set in options
257
- $height = get_option( "{$s}_size_h" );
258
- }
259
- //crop
260
- if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) {// theme-added size
261
- $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
262
- } else { // default sizes set in options
263
- $crop = get_option( "{$s}_crop" );
264
- }
265
- //join
266
- $sizes[$s] = array(
267
- 'width' => $width,
268
- 'height' => $height,
269
- 'crop' => $crop
270
- );
271
- }
272
- #print_r($sizes);
273
- return $sizes;
274
- }
275
-
276
- function getOptions() {
277
- return get_option($this->optionsKey);
278
- }
279
-
280
- function getNonceBase() {
281
- return 'crop-post-thumbnails-nonce-base';
282
- }
283
- }
284
- $cptSettings = new CropThumbnailsSettings();
285
  ?>
1
+ <?php
2
+ class CropThumbnailsSettings {
3
+ private $uniqeSettingsId = 'cpt-settings';
4
+ private $optionsKey = 'crop-post-thumbs';
5
+ private $cssPrefix = 'cpt_settings_';
6
+ private $standardSizes = array('thumbnail','medium','large');
7
+
8
+ function __construct() {
9
+ add_action('admin_menu', array($this,'addOptionsPage'));
10
+ if(is_admin()) {
11
+ add_filter('plugin_action_links', array($this,'addSettingsLinkToPluginPage'), 10, 2);
12
+ add_action('admin_head', array($this,'optionsPageStyle'));
13
+ }
14
+ }
15
+
16
+ function optionsPageStyle() {
17
+ if(!empty($_REQUEST['page']) && $_REQUEST['page']=='page-cpt') {
18
+ wp_enqueue_style('crop-thumbnails-options-style',plugins_url('css/options.css',dirname(__FILE__)));
19
+ }
20
+ }
21
+
22
+ function addSettingsLinkToPluginPage($links, $file) {
23
+ if ($file === 'crop-thumbnails/crop-thumbnails.php'){
24
+ $settings_link = '<a href="options-general.php?page=page-cpt" title="">'.__('Settings',CROP_THUMBS_LANG).'</a>';
25
+ array_unshift( $links, $settings_link );
26
+ }
27
+ return $links;
28
+ }
29
+
30
+ function addOptionsPage() {
31
+ add_options_page(__('Crop Post Thumbnail Page',CROP_THUMBS_LANG), 'Crop-Thumbnails', 'manage_options', 'page-cpt', array($this,'optionsPage'));
32
+ add_action('admin_init', array($this,'settingsInitialisation'));
33
+ }
34
+
35
+ function optionsPage() { ?>
36
+ <div class="wrap">
37
+ <div id="icon-options-general" class="icon32"><br /></div>
38
+ <h2>Crop-Thumbnails <?php esc_attr_e('Settings',CROP_THUMBS_LANG); ?></h2>
39
+ <form action="options.php" method="post">
40
+ <?php settings_fields($this->uniqeSettingsId); ?>
41
+ <?php do_settings_sections('page1'); ?>
42
+
43
+ <div class="<?php echo $this->cssPrefix ?>submit">
44
+ <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes',CROP_THUMBS_LANG); ?>" class="button-primary" />
45
+ </div>
46
+ </form>
47
+
48
+ <div class="<?php echo $this->cssPrefix; ?>paypal">
49
+ <h3><?php _e('Support the plugin-author',CROP_THUMBS_LANG) ?></h3>
50
+ <p><?php _e('You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!',CROP_THUMBS_LANG); ?></p>
51
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
52
+ <input type="hidden" name="cmd" value="_donations">
53
+ <input type="hidden" name="business" value="volkmar.kantor@gmx.de">
54
+ <input type="hidden" name="lc" value="DE">
55
+ <input type="hidden" name="item_name" value="Volkmar Kantor - totalmedial.de">
56
+ <input type="hidden" name="item_number" value="crop-thumbnails">
57
+ <input type="hidden" name="no_note" value="0">
58
+ <input type="hidden" name="currency_code" value="EUR">
59
+ <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
60
+ <input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">
61
+ <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
62
+ </form>
63
+ </div>
64
+ </div>
65
+ <?php
66
+ }
67
+
68
+ function settingsInitialisation(){
69
+ register_setting( $this->uniqeSettingsId, $this->optionsKey, array($this,'validateSettings') );
70
+
71
+ $_sectionID = 'choose_sizes_section';
72
+ add_settings_section($_sectionID, __('Sizes and Posttypes',CROP_THUMBS_LANG), array($this,'sectionDescriptionChooseSizes'), 'page1');
73
+ add_settings_field('sizes', __('Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries.',CROP_THUMBS_LANG), array($this,'callback_choose_size'), 'page1', $_sectionID);
74
+ /*
75
+ $_sectionID = 'experimental';
76
+ add_settings_section($_sectionID, __('Experimental Settings',CROP_THUMBS_LANG), array($this,'emptySectionDescription'), 'page1');
77
+ $_tmpID = 'allow_non_cropped';
78
+ add_settings_field($_tmpID, __('Allow non cropped image-sizes.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
79
+ */
80
+ $_sectionID = 'developer';
81
+ add_settings_section($_sectionID, __('Developer Settings',CROP_THUMBS_LANG), array($this,'emptySectionDescription'), 'page1');
82
+ $_tmpID = 'debug_js';
83
+ add_settings_field($_tmpID, __('Enable JS-Debug.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
84
+ $_tmpID = 'debug_data';
85
+ add_settings_field($_tmpID, __('Enable Data-Debug.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID ));
86
+ }
87
+
88
+ function sectionDescriptionChooseSizes() {?>
89
+ <p>
90
+ <?php _e('Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface.',CROP_THUMBS_LANG) ?>
91
+ <br /><strong><?php _e('Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden.',CROP_THUMBS_LANG); ?></strong>
92
+ </p>
93
+ <?php
94
+ }
95
+
96
+ function emptySectionDescription() {/*empty*/ }
97
+
98
+ function callback_choose_size() {
99
+ //get all the data
100
+ $options = get_option($this->optionsKey);
101
+ #echo '<pre>'.print_r($options,true).'</pre>';
102
+ $post_types = $this->getPostTypes();
103
+ $image_sizes = $this->getImageSizes();
104
+
105
+ //output
106
+ echo '<ul>';
107
+ foreach($post_types as $post_type=>$value) { ?>
108
+ <li>
109
+ <label for="<?php echo $this->cssPrefix.$post_type; ?>">
110
+ <input id="<?php echo $this->cssPrefix.$post_type;?>" type="checkbox" name="<?php echo $this->optionsKey; ?>[hide_post_type][<?php echo $post_type;?>]" value="1" <?php checked(isset($options['hide_post_type'][$post_type]),true); ?> />
111
+ <strong><?php echo $value->labels->name; ?></strong>
112
+ </label>
113
+ <ul style="margin:1em;">
114
+ <?php
115
+
116
+ foreach($image_sizes as $thumb_name => $data) :
117
+ $_checked = false;
118
+ if(!empty($options['hide_size']) && is_array($options['hide_size']) && !empty($options['hide_size'][$post_type][$thumb_name])) {
119
+ $_checked = true;
120
+ }
121
+ if($data['crop']=='1') :
122
+ ?>
123
+ <li>
124
+ <label for="<?php echo $this->cssPrefix.$post_type;?>-<?php echo $thumb_name;?>">
125
+ <input id="<?php echo $this->cssPrefix.$post_type;?>-<?php echo $thumb_name;?>" type="checkbox" name="<?php echo $this->optionsKey; ?>[hide_size][<?php echo $post_type; ?>][<?php echo $thumb_name; ?>]" value="1" <?php echo checked($_checked); ?> />
126
+ <?php echo $thumb_name;?> - <?php echo $data['width'];?>x<?php echo $data['height'];?> <?php /* echo ($data['crop'] == '1' ? '(cropped)' : '') */?>
127
+ </label>
128
+ </li>
129
+ <?php endif; ?>
130
+ <?php endforeach ?>
131
+ </ul>
132
+ <hr />
133
+ </li>
134
+ <?php
135
+ }
136
+ echo '</ul>';
137
+ }
138
+
139
+ function callback_allow_non_cropped() {
140
+ $options = get_option($this->optionsKey);
141
+ $_id = 'allow_non_cropped';
142
+ if(empty($options[$_id])) { $options[$_id] = ''; }
143
+ echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false) . ' />';
144
+ ?>
145
+ <div class="info">
146
+ <?php _e('ATTENTION: be aware that you can break things, when you activate this. When activated your are able to cut those images to a spezific dimension that are not cropped. The name of the image will not change. You should be extra carefull when:',CROP_THUMBS_LANG) ?>
147
+ <ul>
148
+ <li><?php _e('you had inserted the image before on any page or post. (There may be height and width stored directly in the page-content.)',CROP_THUMBS_LANG); ?></li>
149
+ <li><?php _e('you use a plugin that expect the original image size. (The original image-size is also "stored" in the filename.)',CROP_THUMBS_LANG); ?></li>
150
+ </ul>
151
+ <p><?php _e('The "full" image-size will never be cropped, otherwise you are not able to restore any image-size.',CROP_THUMBS_LANG); ?></p>
152
+ </div>
153
+ <?php
154
+ }
155
+
156
+ function callback_debug_js() {
157
+ $options = get_option($this->optionsKey);
158
+ $_id = 'debug_js';
159
+ if(empty($options[$_id])) { $options[$_id] = ''; }
160
+ echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false) . ' />';
161
+ }
162
+
163
+ function callback_debug_data() {
164
+ $options = get_option($this->optionsKey);
165
+ $_id = 'debug_data';
166
+ if(empty($options[$_id])) { $options[$_id] = ''; }
167
+ echo '<input name="'.$this->optionsKey.'['.$_id.']" id="'.$this->cssPrefix.$_id.'" type="checkbox" value="1" ' . checked( 1, $options[$_id], false ) . ' />';
168
+ }
169
+
170
+ function validateSettings($input) {
171
+ $sizes = $this->getImageSizes();
172
+
173
+ $post_types = $this->getPostTypes();
174
+
175
+ $storeInDb = array();
176
+ //check input[hide_post_type] --> are the post_types real there
177
+ if(!empty($input['hide_post_type'])) {
178
+ foreach($input['hide_post_type'] as $_post_type_name=>$value) {
179
+ if(isset($post_types[$_post_type_name])) {
180
+ $storeInDb['hide_post_type'][$_post_type_name] = '1';
181
+ }
182
+ }
183
+ }
184
+
185
+
186
+ //check $input[sizes] --> are post_types correct, are sizes real there
187
+ if(!empty($input['hide_size'])) {
188
+ foreach($input['hide_size'] as $_post_type_name=>$size_type) {
189
+ if(isset($post_types[$_post_type_name])) {
190
+ foreach($size_type as $_size_name=>$value) {
191
+ if(isset($sizes[$_size_name])) {
192
+ $storeInDb['hide_size'][$_post_type_name][$_size_name] = '1';
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ /* Experimental Section */
200
+ $_tmpID = 'allow_non_cropped';
201
+ if(!empty($input[$_tmpID])) {
202
+ $storeInDb[$_tmpID] = 1;
203
+ }
204
+
205
+ /* Advanced Section */
206
+ $_tmpID = 'debug_js';
207
+ if(!empty($input[$_tmpID])) {
208
+ $storeInDb[$_tmpID] = 1;
209
+ }
210
+
211
+ $_tmpID = 'debug_data';
212
+ if(!empty($input[$_tmpID])) {
213
+ $storeInDb[$_tmpID] = 1;
214
+ }
215
+
216
+ return $storeInDb;
217
+ }
218
+
219
+ /* helper functions **********************************************************************************************/
220
+
221
+
222
+ /**
223
+ * get the post types and delete some prebuild post types that we dont need
224
+ */
225
+ function getPostTypes() {
226
+ $post_types = get_post_types(array(),'objects');
227
+ unset($post_types['nav_menu_item']);
228
+ unset($post_types['revision']);
229
+ unset($post_types['attachment']);
230
+ return $post_types;
231
+ }
232
+
233
+
234
+ /**
235
+ * Creates an array of all image sizes:
236
+ * array[sizename][height]
237
+ * array[sizename][width]
238
+ * array[sizename][crop] = boolean
239
+ *
240
+ * Thanks to the ajax_thumbnail_rebuild plugin and post-thumbnail-editor
241
+ */
242
+ function getImageSizes() {
243
+ global $_wp_additional_image_sizes;//array with the available image sizes
244
+ $tmp_sizes = get_intermediate_image_sizes();
245
+ $sizes = array();
246
+ foreach ($tmp_sizes as $s){
247
+ //width
248
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {// theme-added size
249
+ $width = intval( $_wp_additional_image_sizes[$s]['width'] );
250
+ } else { // default sizes set in options
251
+ $width = get_option( "{$s}_size_w" );
252
+ }
253
+ //height
254
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) {// theme-added size
255
+ $height = intval( $_wp_additional_image_sizes[$s]['height'] );
256
+ } else { // default sizes set in options
257
+ $height = get_option( "{$s}_size_h" );
258
+ }
259
+ //crop
260
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) {// theme-added size
261
+ $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
262
+ } else { // default sizes set in options
263
+ $crop = get_option( "{$s}_crop" );
264
+ }
265
+ //join
266
+ $sizes[$s] = array(
267
+ 'width' => $width,
268
+ 'height' => $height,
269
+ 'crop' => $crop
270
+ );
271
+ }
272
+ #print_r($sizes);
273
+ return $sizes;
274
+ }
275
+
276
+ function getOptions() {
277
+ return get_option($this->optionsKey);
278
+ }
279
+
280
+ function getNonceBase() {
281
+ return 'crop-post-thumbnails-nonce-base';
282
+ }
283
+ }
284
+ $cptSettings = new CropThumbnailsSettings();
285
  ?>
html/template.php CHANGED
@@ -1,17 +1,17 @@
1
- <!DOCTYPE HTML>
2
- <html>
3
- <head>
4
- <title>test</title>
5
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
6
- <?php wp_print_styles(); ?>
7
- <?php wp_print_scripts(); ?>
8
- <script type="text/javascript" charset="utf-8">
9
- var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
10
- </script>
11
- <?php if(isset($cptScript)) {echo $cptScript;} ?>
12
- </head>
13
- <body>
14
- <?php if(isset($cptContent)) {echo $cptContent;} ?>
15
- </body>
16
- </html>
17
 
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title>test</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
6
+ <?php wp_print_styles(); ?>
7
+ <?php wp_print_scripts(); ?>
8
+ <script type="text/javascript" charset="utf-8">
9
+ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
10
+ </script>
11
+ <?php if(isset($cptScript)) {echo $cptScript;} ?>
12
+ </head>
13
+ <body>
14
+ <?php if(isset($cptContent)) {echo $cptContent;} ?>
15
+ </body>
16
+ </html>
17
 
js/cpt-crop.js CHANGED
@@ -1,236 +1,236 @@
1
- jQuery(document).ready(function($) {
2
- var pluginpath = '../wp-content/plugins/crop-thumbnails';
3
- var adminAjaxPath = '../wp-admin/admin-ajax.php';
4
-
5
- //setup for ajax connections
6
- $.ajaxSetup({type:'POST', url:adminAjaxPath, cache:false, timeout: (30 * 1000)});
7
-
8
- //cropping object: holds jcrop-object and image to use the crop on
9
- var cropping = {api:-1, img : $('.selectionArea img')};
10
-
11
- /*needed cause the js-logic is currently not handle the hidden objects in dependence with "select all of the same ratio"*/
12
- $('.thumbnail-list li.hidden').remove();
13
-
14
- cropping.img.fadeTo(0, 0.3);
15
-
16
- //handle click on an entry
17
- $('.thumbnail-list li').click(function() {
18
- selectAllWithSameRatio($(this));
19
- activateArea(cropping);
20
- });
21
-
22
-
23
- //handle checkbox for selecting all with same ratio
24
- $('#cpt-same-ratio').change(function() {
25
- var active = $('.thumbnail-list li.active');
26
- if($(this).attr('checked')==='checked') {
27
- if(active.length>0) {
28
- selectAllWithSameRatio($(active[0]));
29
- activateArea(cropping);
30
- }
31
- } else {
32
- if(active.length>1) {
33
- $('.thumbnail-list li').removeClass('active');
34
- deactivateArea(cropping);
35
- }
36
- }
37
- });
38
-
39
-
40
- $('#cpt-deselect').click(function() {
41
- $('.thumbnail-list li.active').removeClass('active');
42
- deactivateArea(cropping);
43
- });
44
-
45
-
46
- $('#cpt-generate').click(function() {
47
- var active = $('.thumbnail-list li.active');
48
- if(active.length===0) {
49
- alert(cpt_lang['selectOne']);
50
- return;
51
- }
52
- var selection = cropping.api.tellSelect();
53
- if(active.length>0 && selection.w>0 && selection.h>0) {
54
- doProcessing(active,cropping);
55
- }
56
- });
57
-
58
-
59
- $('.cpt-debug .cpt-debug-handle').click(function(e) {
60
- e.preventDefault();
61
- $('.cpt-debug').toggleClass('closed');
62
- });
63
-
64
- /********************************/
65
- function doProcessing(active,cropping) {
66
- /*console.log('doProcessing');*/
67
-
68
- var active_array = new Array();
69
- active.find('img').each(function() {
70
- active_array.push($(this).data('values'));
71
- });
72
-
73
- $('.mainWindow').hide();
74
- $('.waitingWindow').show();
75
-
76
- $.ajax({
77
- data:{
78
- action: 'cptSaveThumbnail',
79
- '_ajax_nonce': cpt_ajax_nonce,
80
- cookie: encodeURIComponent(document.cookie),
81
- selection: JSON.stringify(cropping.api.tellSelect()),
82
- raw_values: JSON.stringify(cropping.img.data('values')),
83
- active_values: JSON.stringify(active_array)
84
- },
85
- complete : function() {
86
- $('.mainWindow').show();
87
- $('.waitingWindow').hide();
88
- },
89
- success : function( response ) {
90
- try {
91
- var result = JSON.parse(response);
92
-
93
- if(cpt_debug_js) {
94
- console.log('Save Function Debug',result.debug);
95
- }
96
-
97
- if(typeof result.success == "number") {
98
-
99
- if(result.changed_image_format) {
100
- window.location.reload();
101
- } else {
102
- doCacheBreaker(result.success);
103
- }
104
- } else {
105
- //saving fail
106
- alert(result.error);
107
- }
108
- } catch(e) {
109
- alert(e.message+"\n"+response);
110
- }
111
-
112
- }
113
- });
114
- }
115
-
116
- function doCacheBreaker(number) {
117
- $('.thumbnail-list li img').each(function() {
118
- var imgurl = $(this).attr('src');
119
- var last = imgurl.lastIndexOf('?');
120
- if(last<0) {
121
- imgurl+='?'+number;
122
- } else {
123
- imgurl = imgurl.substring(0, last) + '?'+number;
124
- }
125
- $(this).attr('src',imgurl);
126
- });
127
- }
128
-
129
- function selectAllWithSameRatio(elem) {
130
- $('.thumbnail-list li').removeClass('active');
131
- if($('#cpt-same-ratio').attr('checked')==='checked') {
132
- var ratio = elem.attr('rel');
133
- var elements = $('.thumbnail-list li[rel="'+ratio+'"]');
134
- elements.addClass('active');
135
- } else {
136
- elem.addClass('active');
137
- }
138
- }
139
-
140
-
141
- function deactivateArea(c) {
142
- if(c.api!=-1) {
143
- c.api.release();
144
- c.api.disable();
145
- }
146
- }
147
-
148
- function activateArea(c) {
149
- deactivateArea(c);
150
- var allActiveThumbs = $('.thumbnail-list li.active img');
151
- var largestWidth = 0;
152
- var largestHeight = 0;
153
- var ratio = 0;
154
- var crop = true;
155
-
156
-
157
- //get the options
158
- allActiveThumbs.each(function() {
159
- var img_data = $(this).data('values');
160
- if(ratio === 0) {
161
- ratio = img_data.ratio;//initial
162
- }
163
- if(ratio != img_data.ratio) {
164
- //alert(cpt_lang['bug']);
165
- //TODO: test if this is still needed
166
- }
167
-
168
- //we only need to check in one dimension, cause per definition all selected images have to use the same ratio
169
- if(img_data.width > largestWidth) {
170
- largestWidth = img_data.width;
171
- largestHeight = img_data.height;
172
- }
173
-
174
- //crop also has to be the same on all selected images
175
- if(img_data.crop==1) {
176
- crop = true;
177
- } else {
178
- crop = false;
179
- }
180
- });
181
-
182
- var scale = 0;
183
- if(ratio>=0) {
184
- scale = c.img.data('values').height / largestHeight;
185
- } else {
186
- scale = c.img.data('values').width / largestWidth;
187
- }
188
-
189
- var preSelect = [ 0, 0, Math.round(scale*c.img.width()), Math.round(scale*c.img.height()) ];
190
- var minSize = [ largestWidth, largestHeight ];
191
- // END get the options
192
-
193
- //set the options
194
- var options = {}
195
- options.boxWidth = c.img.width();
196
- options.boxHeight = c.img.height();
197
- options.trueSize = [cropping.img.data('values').width,c.img.data('values').height];
198
- options.aspectRatio = ratio;
199
- options.setSelect = preSelect;
200
-
201
- if(largestWidth>cropping.img.data('values').width || largestHeight>cropping.img.data('values').height) {
202
- alert(cpt_lang['warningOriginalToSmall']);
203
- } else {
204
- options.minSize = minSize;
205
- }
206
-
207
- //correct some options
208
- if(ratio>=0) {
209
- //add a offset to move the selection in the middle
210
- var crop_offset = (cropping.img.data('values').width - scale * largestWidth ) / 2;
211
- options.setSelect = [ crop_offset, 0, cropping.img.data('values').width, Math.round(scale*c.img.height()) ];
212
- } else {
213
- //no offset cause in most cases the the selection is needed in the upper corner (human portrait)
214
- options.setSelect = [ 0, 0, Math.round(scale*c.img.width()) , cropping.img.data('values').height];
215
- }
216
-
217
- if(scale===Infinity) {
218
- options.setSelect = [ 0, 0, Math.round(scale*c.img.width()) , cropping.img.data('values').height];
219
- }
220
-
221
- //free scaling
222
- if(!crop) {
223
- options.aspectRatio = false;
224
- options.setSelect = [0,0,cropping.img.data('values').width,cropping.img.data('values').height];
225
- console.log('free scaling');
226
- }
227
-
228
- //debug
229
- if(cpt_debug_js) {
230
- console.log('choosed image - data',c.img.data('values'));
231
- console.log('JCrop - options',options);
232
- }
233
-
234
- c.api = $.Jcrop(c.img, options);
235
- }
236
  });
1
+ jQuery(document).ready(function($) {
2
+ var pluginpath = '../wp-content/plugins/crop-thumbnails';
3
+ var adminAjaxPath = '../wp-admin/admin-ajax.php';
4
+
5
+ //setup for ajax connections
6
+ $.ajaxSetup({type:'POST', url:adminAjaxPath, cache:false, timeout: (30 * 1000)});
7
+
8
+ //cropping object: holds jcrop-object and image to use the crop on
9
+ var cropping = {api:-1, img : $('.selectionArea img')};
10
+
11
+ /*needed cause the js-logic is currently not handle the hidden objects in dependence with "select all of the same ratio"*/
12
+ $('.thumbnail-list li.hidden').remove();
13
+
14
+ cropping.img.fadeTo(0, 0.3);
15
+
16
+ //handle click on an entry
17
+ $('.thumbnail-list li').click(function() {
18
+ selectAllWithSameRatio($(this));
19
+ activateArea(cropping);
20
+ });
21
+
22
+
23
+ //handle checkbox for selecting all with same ratio
24
+ $('#cpt-same-ratio').change(function() {
25
+ var active = $('.thumbnail-list li.active');
26
+ if($(this).attr('checked')==='checked') {
27
+ if(active.length>0) {
28
+ selectAllWithSameRatio($(active[0]));
29
+ activateArea(cropping);
30
+ }
31
+ } else {
32
+ if(active.length>1) {
33
+ $('.thumbnail-list li').removeClass('active');
34
+ deactivateArea(cropping);
35
+ }
36
+ }
37
+ });
38
+
39
+
40
+ $('#cpt-deselect').click(function() {
41
+ $('.thumbnail-list li.active').removeClass('active');
42
+ deactivateArea(cropping);
43
+ });
44
+
45
+
46
+ $('#cpt-generate').click(function() {
47
+ var active = $('.thumbnail-list li.active');
48
+ if(active.length===0) {
49
+ alert(cpt_lang['selectOne']);
50
+ return;
51
+ }
52
+ var selection = cropping.api.tellSelect();
53
+ if(active.length>0 && selection.w>0 && selection.h>0) {
54
+ doProcessing(active,cropping);
55
+ }
56
+ });
57
+
58
+
59
+ $('.cpt-debug .cpt-debug-handle').click(function(e) {
60
+ e.preventDefault();
61
+ $('.cpt-debug').toggleClass('closed');
62
+ });
63
+
64
+ /********************************/
65
+ function doProcessing(active,cropping) {
66
+ /*console.log('doProcessing');*/
67
+
68
+ var active_array = new Array();
69
+ active.find('img').each(function() {
70
+ active_array.push($(this).data('values'));
71
+ });
72
+
73
+ $('.mainWindow').hide();
74
+ $('.waitingWindow').show();
75
+
76
+ $.ajax({
77
+ data:{
78
+ action: 'cptSaveThumbnail',
79
+ '_ajax_nonce': cpt_ajax_nonce,
80
+ cookie: encodeURIComponent(document.cookie),
81
+ selection: JSON.stringify(cropping.api.tellSelect()),
82
+ raw_values: JSON.stringify(cropping.img.data('values')),
83
+ active_values: JSON.stringify(active_array)
84
+ },
85
+ complete : function() {
86
+ $('.mainWindow').show();
87
+ $('.waitingWindow').hide();
88
+ },
89
+ success : function( response ) {
90
+ try {
91
+ var result = JSON.parse(response);
92
+
93
+ if(cpt_debug_js) {
94
+ console.log('Save Function Debug',result.debug);
95
+ }
96
+
97
+ if(typeof result.success == "number") {
98
+
99
+ if(result.changed_image_format) {
100
+ window.location.reload();
101
+ } else {
102
+ doCacheBreaker(result.success);
103
+ }
104
+ } else {
105
+ //saving fail
106
+ alert(result.error);
107
+ }
108
+ } catch(e) {
109
+ alert(e.message+"\n"+response);
110
+ }
111
+
112
+ }
113
+ });
114
+ }
115
+
116
+ function doCacheBreaker(number) {
117
+ $('.thumbnail-list li img').each(function() {
118
+ var imgurl = $(this).attr('src');
119
+ var last = imgurl.lastIndexOf('?');
120
+ if(last<0) {
121
+ imgurl+='?'+number;
122
+ } else {
123
+ imgurl = imgurl.substring(0, last) + '?'+number;
124
+ }
125
+ $(this).attr('src',imgurl);
126
+ });
127
+ }
128
+
129
+ function selectAllWithSameRatio(elem) {
130
+ $('.thumbnail-list li').removeClass('active');
131
+ if($('#cpt-same-ratio').attr('checked')==='checked') {
132
+ var ratio = elem.attr('rel');
133
+ var elements = $('.thumbnail-list li[rel="'+ratio+'"]');
134
+ elements.addClass('active');
135
+ } else {
136
+ elem.addClass('active');
137
+ }
138
+ }
139
+
140
+
141
+ function deactivateArea(c) {
142
+ if(c.api!=-1) {
143
+ c.api.release();
144
+ c.api.disable();
145
+ }
146
+ }
147
+
148
+ function activateArea(c) {
149
+ deactivateArea(c);
150
+ var allActiveThumbs = $('.thumbnail-list li.active img');
151
+ var largestWidth = 0;
152
+ var largestHeight = 0;
153
+ var ratio = 0;
154
+ var crop = true;
155
+
156
+
157
+ //get the options
158
+ allActiveThumbs.each(function() {
159
+ var img_data = $(this).data('values');
160
+ if(ratio === 0) {
161
+ ratio = img_data.ratio;//initial
162
+ }
163
+ if(ratio != img_data.ratio) {
164
+ //alert(cpt_lang['bug']);
165
+ //TODO: test if this is still needed
166
+ }
167
+
168
+ //we only need to check in one dimension, cause per definition all selected images have to use the same ratio
169
+ if(img_data.width > largestWidth) {
170
+ largestWidth = img_data.width;
171
+ largestHeight = img_data.height;
172
+ }
173
+
174
+ //crop also has to be the same on all selected images
175
+ if(img_data.crop==1) {
176
+ crop = true;
177
+ } else {
178
+ crop = false;
179
+ }
180
+ });
181
+
182
+ var scale = 0;
183
+ if(ratio>=0) {
184
+ scale = c.img.data('values').height / largestHeight;
185
+ } else {
186
+ scale = c.img.data('values').width / largestWidth;
187
+ }
188
+
189
+ var preSelect = [ 0, 0, Math.round(scale*c.img.width()), Math.round(scale*c.img.height()) ];
190
+ var minSize = [ largestWidth, largestHeight ];
191
+ // END get the options
192
+
193
+ //set the options
194
+ var options = {}
195
+ options.boxWidth = c.img.width();
196
+ options.boxHeight = c.img.height();
197
+ options.trueSize = [cropping.img.data('values').width,c.img.data('values').height];
198
+ options.aspectRatio = ratio;
199
+ options.setSelect = preSelect;
200
+
201
+ if(largestWidth>cropping.img.data('values').width || largestHeight>cropping.img.data('values').height) {
202
+ alert(cpt_lang['warningOriginalToSmall']);
203
+ } else {
204
+ options.minSize = minSize;
205
+ }
206
+
207
+ //correct some options
208
+ if(ratio>=0) {
209
+ //add a offset to move the selection in the middle
210
+ var crop_offset = (cropping.img.data('values').width - scale * largestWidth ) / 2;
211
+ options.setSelect = [ crop_offset, 0, cropping.img.data('values').width, Math.round(scale*c.img.height()) ];
212
+ } else {
213
+ //no offset cause in most cases the the selection is needed in the upper corner (human portrait)
214
+ options.setSelect = [ 0, 0, Math.round(scale*c.img.width()) , cropping.img.data('values').height];
215
+ }
216
+
217
+ if(scale===Infinity) {
218
+ options.setSelect = [ 0, 0, Math.round(scale*c.img.width()) , cropping.img.data('values').height];
219
+ }
220
+
221
+ //free scaling
222
+ if(!crop) {
223
+ options.aspectRatio = false;
224
+ options.setSelect = [0,0,cropping.img.data('values').width,cropping.img.data('values').height];
225
+ console.log('free scaling');
226
+ }
227
+
228
+ //debug
229
+ if(cpt_debug_js) {
230
+ console.log('choosed image - data',c.img.data('values'));
231
+ console.log('JCrop - options',options);
232
+ }
233
+
234
+ c.api = $.Jcrop(c.img, options);
235
+ }
236
  });
js/jcrop/css/jquery.Jcrop.min.css CHANGED
@@ -1,29 +1,29 @@
1
- /* jquery.Jcrop.min.css v0.9.12 (build:20130126) */
2
- .jcrop-holder{direction:ltr;text-align:left;}
3
- .jcrop-vline,.jcrop-hline{background:#FFF url(Jcrop.gif);font-size:0;position:absolute;}
4
- .jcrop-vline{height:100%;width:1px!important;}
5
- .jcrop-vline.right{right:0;}
6
- .jcrop-hline{height:1px!important;width:100%;}
7
- .jcrop-hline.bottom{bottom:0;}
8
- .jcrop-tracker{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;height:100%;width:100%;}
9
- .jcrop-handle{background-color:#333;border:1px #EEE solid;font-size:1px;height:7px;width:7px;}
10
- .jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0;}
11
- .jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px;}
12
- .jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%;}
13
- .jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%;}
14
- .jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0;}
15
- .jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0;}
16
- .jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0;}
17
- .jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px;}
18
- .jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%;}
19
- .jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px;}
20
- .jcrop-dragbar.ord-n{margin-top:-4px;}
21
- .jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px;}
22
- .jcrop-dragbar.ord-e{margin-right:-4px;right:0;}
23
- .jcrop-dragbar.ord-w{margin-left:-4px;}
24
- .jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#FFF;filter:alpha(opacity=70)!important;opacity:.70!important;}
25
- .jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px;}
26
- .jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important;}
27
- .jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px;}
28
- .solid-line .jcrop-vline,.solid-line .jcrop-hline{background:#FFF;}
29
  .jcrop-holder img,img.jcrop-preview{max-width:none;}
1
+ /* jquery.Jcrop.min.css v0.9.12 (build:20130126) */
2
+ .jcrop-holder{direction:ltr;text-align:left;}
3
+ .jcrop-vline,.jcrop-hline{background:#FFF url(Jcrop.gif);font-size:0;position:absolute;}
4
+ .jcrop-vline{height:100%;width:1px!important;}
5
+ .jcrop-vline.right{right:0;}
6
+ .jcrop-hline{height:1px!important;width:100%;}
7
+ .jcrop-hline.bottom{bottom:0;}
8
+ .jcrop-tracker{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;height:100%;width:100%;}
9
+ .jcrop-handle{background-color:#333;border:1px #EEE solid;font-size:1px;height:7px;width:7px;}
10
+ .jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0;}
11
+ .jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px;}
12
+ .jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%;}
13
+ .jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%;}
14
+ .jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0;}
15
+ .jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0;}
16
+ .jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0;}
17
+ .jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px;}
18
+ .jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%;}
19
+ .jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px;}
20
+ .jcrop-dragbar.ord-n{margin-top:-4px;}
21
+ .jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px;}
22
+ .jcrop-dragbar.ord-e{margin-right:-4px;right:0;}
23
+ .jcrop-dragbar.ord-w{margin-left:-4px;}
24
+ .jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#FFF;filter:alpha(opacity=70)!important;opacity:.70!important;}
25
+ .jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px;}
26
+ .jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important;}
27
+ .jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px;}
28
+ .solid-line .jcrop-vline,.solid-line .jcrop-hline{background:#FFF;}
29
  .jcrop-holder img,img.jcrop-preview{max-width:none;}
js/jcrop/js/jquery.Jcrop.min.js CHANGED
@@ -1,22 +1,22 @@
1
- /**
2
- * jquery.Jcrop.min.js v0.9.12 (build:20130202)
3
- * jQuery Image Cropping Plugin - released under MIT License
4
- * Copyright (c) 2008-2013 Tapmodo Interactive LLC
5
- * https://github.com/tapmodo/Jcrop
6
- */
7
- (function(a){a.Jcrop=function(b,c){function i(a){return Math.round(a)+"px"}function j(a){return d.baseClass+"-"+a}function k(){return a.fx.step.hasOwnProperty("backgroundColor")}function l(b){var c=a(b).offset();return[c.left,c.top]}function m(a){return[a.pageX-e[0],a.pageY-e[1]]}function n(b){typeof b!="object"&&(b={}),d=a.extend(d,b),a.each(["onChange","onSelect","onRelease","onDblClick"],function(a,b){typeof d[b]!="function"&&(d[b]=function(){})})}function o(a,b,c){e=l(D),bc.setCursor(a==="move"?a:a+"-resize");if(a==="move")return bc.activateHandlers(q(b),v,c);var d=_.getFixed(),f=r(a),g=_.getCorner(r(f));_.setPressed(_.getCorner(f)),_.setCurrent(g),bc.activateHandlers(p(a,d),v,c)}function p(a,b){return function(c){if(!d.aspectRatio)switch(a){case"e":c[1]=b.y2;break;case"w":c[1]=b.y2;break;case"n":c[0]=b.x2;break;case"s":c[0]=b.x2}else switch(a){case"e":c[1]=b.y+1;break;case"w":c[1]=b.y+1;break;case"n":c[0]=b.x+1;break;case"s":c[0]=b.x+1}_.setCurrent(c),bb.update()}}function q(a){var b=a;return bd.watchKeys
8
- (),function(a){_.moveOffset([a[0]-b[0],a[1]-b[1]]),b=a,bb.update()}}function r(a){switch(a){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function s(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=l(D),W=!0,o(a,m(b)),b.stopPropagation(),b.preventDefault(),!1)}}function t(a,b,c){var d=a.width(),e=a.height();d>b&&b>0&&(d=b,e=b/a.width()*a.height()),e>c&&c>0&&(e=c,d=c/a.height()*a.width()),T=a.width()/d,U=a.height()/e,a.width(d).height(e)}function u(a){return{x:a.x*T,y:a.y*U,x2:a.x2*T,y2:a.y2*U,w:a.w*T,h:a.h*U}}function v(a){var b=_.getFixed();b.w>d.minSelect[0]&&b.h>d.minSelect[1]?(bb.enableHandles(),bb.done()):bb.release(),bc.setCursor(d.allowSelect?"crosshair":"default")}function w(a){if(d.disabled)return!1;if(!d.allowSelect)return!1;W=!0,e=l(D),bb.disableHandles(),bc.setCursor("crosshair");var b=m(a);return _.setPressed(b),bb.update(),bc.activateHandlers(x,v,a.type.substring
9
- (0,5)==="touch"),bd.watchKeys(),a.stopPropagation(),a.preventDefault(),!1}function x(a){_.setCurrent(a),bb.update()}function y(){var b=a("<div></div>").addClass(j("tracker"));return g&&b.css({opacity:0,backgroundColor:"white"}),b}function be(a){G.removeClass().addClass(j("holder")).addClass(a)}function bf(a,b){function t(){window.setTimeout(u,l)}var c=a[0]/T,e=a[1]/U,f=a[2]/T,g=a[3]/U;if(X)return;var h=_.flipCoords(c,e,f,g),i=_.getFixed(),j=[i.x,i.y,i.x2,i.y2],k=j,l=d.animationDelay,m=h[0]-j[0],n=h[1]-j[1],o=h[2]-j[2],p=h[3]-j[3],q=0,r=d.swingSpeed;c=k[0],e=k[1],f=k[2],g=k[3],bb.animMode(!0);var s,u=function(){return function(){q+=(100-q)/r,k[0]=Math.round(c+q/100*m),k[1]=Math.round(e+q/100*n),k[2]=Math.round(f+q/100*o),k[3]=Math.round(g+q/100*p),q>=99.8&&(q=100),q<100?(bh(k),t()):(bb.done(),bb.animMode(!1),typeof b=="function"&&b.call(bs))}}();t()}function bg(a){bh([a[0]/T,a[1]/U,a[2]/T,a[3]/U]),d.onSelect.call(bs,u(_.getFixed())),bb.enableHandles()}function bh(a){_.setPressed([a[0],a[1]]),_.setCurrent([a[2],
10
- a[3]]),bb.update()}function bi(){return u(_.getFixed())}function bj(){return _.getFixed()}function bk(a){n(a),br()}function bl(){d.disabled=!0,bb.disableHandles(),bb.setCursor("default"),bc.setCursor("default")}function bm(){d.disabled=!1,br()}function bn(){bb.done(),bc.activateHandlers(null,null)}function bo(){G.remove(),A.show(),A.css("visibility","visible"),a(b).removeData("Jcrop")}function bp(a,b){bb.release(),bl();var c=new Image;c.onload=function(){var e=c.width,f=c.height,g=d.boxWidth,h=d.boxHeight;D.width(e).height(f),D.attr("src",a),H.attr("src",a),t(D,g,h),E=D.width(),F=D.height(),H.width(E).height(F),M.width(E+L*2).height(F+L*2),G.width(E).height(F),ba.resize(E,F),bm(),typeof b=="function"&&b.call(bs)},c.src=a}function bq(a,b,c){var e=b||d.bgColor;d.bgFade&&k()&&d.fadeTime&&!c?a.animate({backgroundColor:e},{queue:!1,duration:d.fadeTime}):a.css("backgroundColor",e)}function br(a){d.allowResize?a?bb.enableOnly():bb.enableHandles():bb.disableHandles(),bc.setCursor(d.allowSelect?"crosshair":"default"),bb
11
- .setCursor(d.allowMove?"move":"default"),d.hasOwnProperty("trueSize")&&(T=d.trueSize[0]/E,U=d.trueSize[1]/F),d.hasOwnProperty("setSelect")&&(bg(d.setSelect),bb.done(),delete d.setSelect),ba.refresh(),d.bgColor!=N&&(bq(d.shade?ba.getShades():G,d.shade?d.shadeColor||d.bgColor:d.bgColor),N=d.bgColor),O!=d.bgOpacity&&(O=d.bgOpacity,d.shade?ba.refresh():bb.setBgOpacity(O)),P=d.maxSize[0]||0,Q=d.maxSize[1]||0,R=d.minSize[0]||0,S=d.minSize[1]||0,d.hasOwnProperty("outerImage")&&(D.attr("src",d.outerImage),delete d.outerImage),bb.refresh()}var d=a.extend({},a.Jcrop.defaults),e,f=navigator.userAgent.toLowerCase(),g=/msie/.test(f),h=/msie [1-6]\./.test(f);typeof b!="object"&&(b=a(b)[0]),typeof c!="object"&&(c={}),n(c);var z={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},A=a(b),B=!0;if(b.tagName=="IMG"){if(A[0].width!=0&&A[0].height!=0)A.width(A[0].width),A.height(A[0].height);else{var C=new Image;C.src=A[0].src,A.width(C.width),A.height(C.height)}var D=A.clone().removeAttr("id").
12
- css(z).show();D.width(A.width()),D.height(A.height()),A.after(D).hide()}else D=A.css(z).show(),B=!1,d.shade===null&&(d.shade=!0);t(D,d.boxWidth,d.boxHeight);var E=D.width(),F=D.height(),G=a("<div />").width(E).height(F).addClass(j("holder")).css({position:"relative",backgroundColor:d.bgColor}).insertAfter(A).append(D);d.addClass&&G.addClass(d.addClass);var H=a("<div />"),I=a("<div />").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),J=a("<div />").width("100%").height("100%").css("zIndex",320),K=a("<div />").css({position:"absolute",zIndex:600}).dblclick(function(){var a=_.getFixed();d.onDblClick.call(bs,a)}).insertBefore(D).append(I,J);B&&(H=a("<img />").attr("src",D.attr("src")).css(z).width(E).height(F),I.append(H)),h&&K.css({overflowY:"hidden"});var L=d.boundary,M=y().width(E+L*2).height(F+L*2).css({position:"absolute",top:i(-L),left:i(-L),zIndex:290}).mousedown(w),N=d.bgColor,O=d.bgOpacity,P,Q,R,S,T,U,V=!0,W,X,Y;e=l(D);var Z=function(){function a(){var a={},b=["touchstart"
13
- ,"touchmove","touchend"],c=document.createElement("div"),d;try{for(d=0;d<b.length;d++){var e=b[d];e="on"+e;var f=e in c;f||(c.setAttribute(e,"return;"),f=typeof c[e]=="function"),a[b[d]]=f}return a.touchstart&&a.touchend&&a.touchmove}catch(g){return!1}}function b(){return d.touchSupport===!0||d.touchSupport===!1?d.touchSupport:a()}return{createDragger:function(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=l(D),W=!0,o(a,m(Z.cfilter(b)),!0),b.stopPropagation(),b.preventDefault(),!1)}},newSelection:function(a){return w(Z.cfilter(a))},cfilter:function(a){return a.pageX=a.originalEvent.changedTouches[0].pageX,a.pageY=a.originalEvent.changedTouches[0].pageY,a},isSupported:a,support:b()}}(),_=function(){function h(d){d=n(d),c=a=d[0],e=b=d[1]}function i(a){a=n(a),f=a[0]-c,g=a[1]-e,c=a[0],e=a[1]}function j(){return[f,g]}function k(d){var f=d[0],g=d[1];0>a+f&&(f-=f+a),0>b+g&&(g-=g+b),F<e+g&&(g+=F-(e+g)),E<c+f&&(f+=E-(c+f)),a+=f,c+=f,b+=g,e+=g}function l(a){var b=m();switch(a){case"ne":return[
14
- b.x2,b.y];case"nw":return[b.x,b.y];case"se":return[b.x2,b.y2];case"sw":return[b.x,b.y2]}}function m(){if(!d.aspectRatio)return p();var f=d.aspectRatio,g=d.minSize[0]/T,h=d.maxSize[0]/T,i=d.maxSize[1]/U,j=c-a,k=e-b,l=Math.abs(j),m=Math.abs(k),n=l/m,r,s,t,u;return h===0&&(h=E*10),i===0&&(i=F*10),n<f?(s=e,t=m*f,r=j<0?a-t:t+a,r<0?(r=0,u=Math.abs((r-a)/f),s=k<0?b-u:u+b):r>E&&(r=E,u=Math.abs((r-a)/f),s=k<0?b-u:u+b)):(r=c,u=l/f,s=k<0?b-u:b+u,s<0?(s=0,t=Math.abs((s-b)*f),r=j<0?a-t:t+a):s>F&&(s=F,t=Math.abs(s-b)*f,r=j<0?a-t:t+a)),r>a?(r-a<g?r=a+g:r-a>h&&(r=a+h),s>b?s=b+(r-a)/f:s=b-(r-a)/f):r<a&&(a-r<g?r=a-g:a-r>h&&(r=a-h),s>b?s=b+(a-r)/f:s=b-(a-r)/f),r<0?(a-=r,r=0):r>E&&(a-=r-E,r=E),s<0?(b-=s,s=0):s>F&&(b-=s-F,s=F),q(o(a,b,r,s))}function n(a){return a[0]<0&&(a[0]=0),a[1]<0&&(a[1]=0),a[0]>E&&(a[0]=E),a[1]>F&&(a[1]=F),[Math.round(a[0]),Math.round(a[1])]}function o(a,b,c,d){var e=a,f=c,g=b,h=d;return c<a&&(e=c,f=a),d<b&&(g=d,h=b),[e,g,f,h]}function p(){var d=c-a,f=e-b,g;return P&&Math.abs(d)>P&&(c=d>0?a+P:a-P),Q&&Math.abs
15
- (f)>Q&&(e=f>0?b+Q:b-Q),S/U&&Math.abs(f)<S/U&&(e=f>0?b+S/U:b-S/U),R/T&&Math.abs(d)<R/T&&(c=d>0?a+R/T:a-R/T),a<0&&(c-=a,a-=a),b<0&&(e-=b,b-=b),c<0&&(a-=c,c-=c),e<0&&(b-=e,e-=e),c>E&&(g=c-E,a-=g,c-=g),e>F&&(g=e-F,b-=g,e-=g),a>E&&(g=a-F,e-=g,b-=g),b>F&&(g=b-F,e-=g,b-=g),q(o(a,b,c,e))}function q(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var a=0,b=0,c=0,e=0,f,g;return{flipCoords:o,setPressed:h,setCurrent:i,getOffset:j,moveOffset:k,getCorner:l,getFixed:m}}(),ba=function(){function f(a,b){e.left.css({height:i(b)}),e.right.css({height:i(b)})}function g(){return h(_.getFixed())}function h(a){e.top.css({left:i(a.x),width:i(a.w),height:i(a.y)}),e.bottom.css({top:i(a.y2),left:i(a.x),width:i(a.w),height:i(F-a.y2)}),e.right.css({left:i(a.x2),width:i(E-a.x2)}),e.left.css({width:i(a.x)})}function j(){return a("<div />").css({position:"absolute",backgroundColor:d.shadeColor||d.bgColor}).appendTo(c)}function k(){b||(b=!0,c.insertBefore(D),g(),bb.setBgOpacity(1,0,1),H.hide(),l(d.shadeColor||d.bgColor,1),bb.
16
- isAwake()?n(d.bgOpacity,1):n(1,1))}function l(a,b){bq(p(),a,b)}function m(){b&&(c.remove(),H.show(),b=!1,bb.isAwake()?bb.setBgOpacity(d.bgOpacity,1,1):(bb.setBgOpacity(1,1,1),bb.disableHandles()),bq(G,0,1))}function n(a,e){b&&(d.bgFade&&!e?c.animate({opacity:1-a},{queue:!1,duration:d.fadeTime}):c.css({opacity:1-a}))}function o(){d.shade?k():m(),bb.isAwake()&&n(d.bgOpacity)}function p(){return c.children()}var b=!1,c=a("<div />").css({position:"absolute",zIndex:240,opacity:0}),e={top:j(),left:j().height(F),right:j().height(F),bottom:j()};return{update:g,updateRaw:h,getShades:p,setBgColor:l,enable:k,disable:m,resize:f,refresh:o,opacity:n}}(),bb=function(){function k(b){var c=a("<div />").css({position:"absolute",opacity:d.borderOpacity}).addClass(j(b));return I.append(c),c}function l(b,c){var d=a("<div />").mousedown(s(b)).css({cursor:b+"-resize",position:"absolute",zIndex:c}).addClass("ord-"+b);return Z.support&&d.bind("touchstart.jcrop",Z.createDragger(b)),J.append(d),d}function m(a){var b=d.handleSize,e=l(a,c++
17
- ).css({opacity:d.handleOpacity}).addClass(j("handle"));return b&&e.width(b).height(b),e}function n(a){return l(a,c++).addClass("jcrop-dragbar")}function o(a){var b;for(b=0;b<a.length;b++)g[a[b]]=n(a[b])}function p(a){var b,c;for(c=0;c<a.length;c++){switch(a[c]){case"n":b="hline";break;case"s":b="hline bottom";break;case"e":b="vline right";break;case"w":b="vline"}e[a[c]]=k(b)}}function q(a){var b;for(b=0;b<a.length;b++)f[a[b]]=m(a[b])}function r(a,b){d.shade||H.css({top:i(-b),left:i(-a)}),K.css({top:i(b),left:i(a)})}function t(a,b){K.width(Math.round(a)).height(Math.round(b))}function v(){var a=_.getFixed();_.setPressed([a.x,a.y]),_.setCurrent([a.x2,a.y2]),w()}function w(a){if(b)return x(a)}function x(a){var c=_.getFixed();t(c.w,c.h),r(c.x,c.y),d.shade&&ba.updateRaw(c),b||A(),a?d.onSelect.call(bs,u(c)):d.onChange.call(bs,u(c))}function z(a,c,e){if(!b&&!c)return;d.bgFade&&!e?D.animate({opacity:a},{queue:!1,duration:d.fadeTime}):D.css("opacity",a)}function A(){K.show(),d.shade?ba.opacity(O):z(O,!0),b=!0}function B
18
- (){F(),K.hide(),d.shade?ba.opacity(1):z(1),b=!1,d.onRelease.call(bs)}function C(){h&&J.show()}function E(){h=!0;if(d.allowResize)return J.show(),!0}function F(){h=!1,J.hide()}function G(a){a?(X=!0,F()):(X=!1,E())}function L(){G(!1),v()}var b,c=370,e={},f={},g={},h=!1;d.dragEdges&&a.isArray(d.createDragbars)&&o(d.createDragbars),a.isArray(d.createHandles)&&q(d.createHandles),d.drawBorders&&a.isArray(d.createBorders)&&p(d.createBorders),a(document).bind("touchstart.jcrop-ios",function(b){a(b.currentTarget).hasClass("jcrop-tracker")&&b.stopPropagation()});var M=y().mousedown(s("move")).css({cursor:"move",position:"absolute",zIndex:360});return Z.support&&M.bind("touchstart.jcrop",Z.createDragger("move")),I.append(M),F(),{updateVisible:w,update:x,release:B,refresh:v,isAwake:function(){return b},setCursor:function(a){M.css("cursor",a)},enableHandles:E,enableOnly:function(){h=!0},showHandles:C,disableHandles:F,animMode:G,setBgOpacity:z,done:L}}(),bc=function(){function f(b){M.css({zIndex:450}),b?a(document).bind("touchmove.jcrop"
19
- ,k).bind("touchend.jcrop",l):e&&a(document).bind("mousemove.jcrop",h).bind("mouseup.jcrop",i)}function g(){M.css({zIndex:290}),a(document).unbind(".jcrop")}function h(a){return b(m(a)),!1}function i(a){return a.preventDefault(),a.stopPropagation(),W&&(W=!1,c(m(a)),bb.isAwake()&&d.onSelect.call(bs,u(_.getFixed())),g(),b=function(){},c=function(){}),!1}function j(a,d,e){return W=!0,b=a,c=d,f(e),!1}function k(a){return b(m(Z.cfilter(a))),!1}function l(a){return i(Z.cfilter(a))}function n(a){M.css("cursor",a)}var b=function(){},c=function(){},e=d.trackDocument;return e||M.mousemove(h).mouseup(i).mouseout(i),D.before(M),{activateHandlers:j,setCursor:n}}(),bd=function(){function e(){d.keySupport&&(b.show(),b.focus())}function f(a){b.hide()}function g(a,b,c){d.allowMove&&(_.moveOffset([b,c]),bb.updateVisible(!0)),a.preventDefault(),a.stopPropagation()}function i(a){if(a.ctrlKey||a.metaKey)return!0;Y=a.shiftKey?!0:!1;var b=Y?10:1;switch(a.keyCode){case 37:g(a,-b,0);break;case 39:g(a,b,0);break;case 38:g(a,0,-b);break;
20
- case 40:g(a,0,b);break;case 27:d.allowSelect&&bb.release();break;case 9:return!0}return!1}var b=a('<input type="radio" />').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),c=a("<div />").css({position:"absolute",overflow:"hidden"}).append(b);return d.keySupport&&(b.keydown(i).blur(f),h||!d.fixedSupport?(b.css({position:"absolute",left:"-20px"}),c.append(b).insertBefore(D)):b.insertBefore(D)),{watchKeys:e}}();Z.support&&M.bind("touchstart.jcrop",Z.newSelection),J.hide(),br(!0);var bs={setImage:bp,animateTo:bf,setSelect:bg,setOptions:bk,tellSelect:bi,tellScaled:bj,setClass:be,disable:bl,enable:bm,cancel:bn,release:bb.release,destroy:bo,focus:bd.watchKeys,getBounds:function(){return[E*T,F*U]},getWidgetSize:function(){return[E,F]},getScaleFactor:function(){return[T,U]},getOptions:function(){return d},ui:{holder:G,selection:K}};return g&&G.bind("selectstart",function(){return!1}),A.data("Jcrop",bs),bs},a.fn.Jcrop=function(b,c){var d;return this.each(function(){if(a(this).data("Jcrop")){if(
21
- b==="api")return a(this).data("Jcrop");a(this).data("Jcrop").setOptions(b)}else this.tagName=="IMG"?a.Jcrop.Loader(this,function(){a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d)}):(a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d))}),this},a.Jcrop.Loader=function(b,c,d){function g(){f.complete?(e.unbind(".jcloader"),a.isFunction(c)&&c.call(f)):window.setTimeout(g,50)}var e=a(b),f=e[0];e.bind("load.jcloader",g).bind("error.jcloader",function(b){e.unbind(".jcloader"),a.isFunction(d)&&d.call(f)}),f.complete&&a.isFunction(c)&&(e.unbind(".jcloader"),c.call(f))},a.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges
22
  :!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}})(jQuery);
1
+ /**
2
+ * jquery.Jcrop.min.js v0.9.12 (build:20130202)
3
+ * jQuery Image Cropping Plugin - released under MIT License
4
+ * Copyright (c) 2008-2013 Tapmodo Interactive LLC
5
+ * https://github.com/tapmodo/Jcrop
6
+ */
7
+ (function(a){a.Jcrop=function(b,c){function i(a){return Math.round(a)+"px"}function j(a){return d.baseClass+"-"+a}function k(){return a.fx.step.hasOwnProperty("backgroundColor")}function l(b){var c=a(b).offset();return[c.left,c.top]}function m(a){return[a.pageX-e[0],a.pageY-e[1]]}function n(b){typeof b!="object"&&(b={}),d=a.extend(d,b),a.each(["onChange","onSelect","onRelease","onDblClick"],function(a,b){typeof d[b]!="function"&&(d[b]=function(){})})}function o(a,b,c){e=l(D),bc.setCursor(a==="move"?a:a+"-resize");if(a==="move")return bc.activateHandlers(q(b),v,c);var d=_.getFixed(),f=r(a),g=_.getCorner(r(f));_.setPressed(_.getCorner(f)),_.setCurrent(g),bc.activateHandlers(p(a,d),v,c)}function p(a,b){return function(c){if(!d.aspectRatio)switch(a){case"e":c[1]=b.y2;break;case"w":c[1]=b.y2;break;case"n":c[0]=b.x2;break;case"s":c[0]=b.x2}else switch(a){case"e":c[1]=b.y+1;break;case"w":c[1]=b.y+1;break;case"n":c[0]=b.x+1;break;case"s":c[0]=b.x+1}_.setCurrent(c),bb.update()}}function q(a){var b=a;return bd.watchKeys
8
+ (),function(a){_.moveOffset([a[0]-b[0],a[1]-b[1]]),b=a,bb.update()}}function r(a){switch(a){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function s(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=l(D),W=!0,o(a,m(b)),b.stopPropagation(),b.preventDefault(),!1)}}function t(a,b,c){var d=a.width(),e=a.height();d>b&&b>0&&(d=b,e=b/a.width()*a.height()),e>c&&c>0&&(e=c,d=c/a.height()*a.width()),T=a.width()/d,U=a.height()/e,a.width(d).height(e)}function u(a){return{x:a.x*T,y:a.y*U,x2:a.x2*T,y2:a.y2*U,w:a.w*T,h:a.h*U}}function v(a){var b=_.getFixed();b.w>d.minSelect[0]&&b.h>d.minSelect[1]?(bb.enableHandles(),bb.done()):bb.release(),bc.setCursor(d.allowSelect?"crosshair":"default")}function w(a){if(d.disabled)return!1;if(!d.allowSelect)return!1;W=!0,e=l(D),bb.disableHandles(),bc.setCursor("crosshair");var b=m(a);return _.setPressed(b),bb.update(),bc.activateHandlers(x,v,a.type.substring
9
+ (0,5)==="touch"),bd.watchKeys(),a.stopPropagation(),a.preventDefault(),!1}function x(a){_.setCurrent(a),bb.update()}function y(){var b=a("<div></div>").addClass(j("tracker"));return g&&b.css({opacity:0,backgroundColor:"white"}),b}function be(a){G.removeClass().addClass(j("holder")).addClass(a)}function bf(a,b){function t(){window.setTimeout(u,l)}var c=a[0]/T,e=a[1]/U,f=a[2]/T,g=a[3]/U;if(X)return;var h=_.flipCoords(c,e,f,g),i=_.getFixed(),j=[i.x,i.y,i.x2,i.y2],k=j,l=d.animationDelay,m=h[0]-j[0],n=h[1]-j[1],o=h[2]-j[2],p=h[3]-j[3],q=0,r=d.swingSpeed;c=k[0],e=k[1],f=k[2],g=k[3],bb.animMode(!0);var s,u=function(){return function(){q+=(100-q)/r,k[0]=Math.round(c+q/100*m),k[1]=Math.round(e+q/100*n),k[2]=Math.round(f+q/100*o),k[3]=Math.round(g+q/100*p),q>=99.8&&(q=100),q<100?(bh(k),t()):(bb.done(),bb.animMode(!1),typeof b=="function"&&b.call(bs))}}();t()}function bg(a){bh([a[0]/T,a[1]/U,a[2]/T,a[3]/U]),d.onSelect.call(bs,u(_.getFixed())),bb.enableHandles()}function bh(a){_.setPressed([a[0],a[1]]),_.setCurrent([a[2],
10
+ a[3]]),bb.update()}function bi(){return u(_.getFixed())}function bj(){return _.getFixed()}function bk(a){n(a),br()}function bl(){d.disabled=!0,bb.disableHandles(),bb.setCursor("default"),bc.setCursor("default")}function bm(){d.disabled=!1,br()}function bn(){bb.done(),bc.activateHandlers(null,null)}function bo(){G.remove(),A.show(),A.css("visibility","visible"),a(b).removeData("Jcrop")}function bp(a,b){bb.release(),bl();var c=new Image;c.onload=function(){var e=c.width,f=c.height,g=d.boxWidth,h=d.boxHeight;D.width(e).height(f),D.attr("src",a),H.attr("src",a),t(D,g,h),E=D.width(),F=D.height(),H.width(E).height(F),M.width(E+L*2).height(F+L*2),G.width(E).height(F),ba.resize(E,F),bm(),typeof b=="function"&&b.call(bs)},c.src=a}function bq(a,b,c){var e=b||d.bgColor;d.bgFade&&k()&&d.fadeTime&&!c?a.animate({backgroundColor:e},{queue:!1,duration:d.fadeTime}):a.css("backgroundColor",e)}function br(a){d.allowResize?a?bb.enableOnly():bb.enableHandles():bb.disableHandles(),bc.setCursor(d.allowSelect?"crosshair":"default"),bb
11
+ .setCursor(d.allowMove?"move":"default"),d.hasOwnProperty("trueSize")&&(T=d.trueSize[0]/E,U=d.trueSize[1]/F),d.hasOwnProperty("setSelect")&&(bg(d.setSelect),bb.done(),delete d.setSelect),ba.refresh(),d.bgColor!=N&&(bq(d.shade?ba.getShades():G,d.shade?d.shadeColor||d.bgColor:d.bgColor),N=d.bgColor),O!=d.bgOpacity&&(O=d.bgOpacity,d.shade?ba.refresh():bb.setBgOpacity(O)),P=d.maxSize[0]||0,Q=d.maxSize[1]||0,R=d.minSize[0]||0,S=d.minSize[1]||0,d.hasOwnProperty("outerImage")&&(D.attr("src",d.outerImage),delete d.outerImage),bb.refresh()}var d=a.extend({},a.Jcrop.defaults),e,f=navigator.userAgent.toLowerCase(),g=/msie/.test(f),h=/msie [1-6]\./.test(f);typeof b!="object"&&(b=a(b)[0]),typeof c!="object"&&(c={}),n(c);var z={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},A=a(b),B=!0;if(b.tagName=="IMG"){if(A[0].width!=0&&A[0].height!=0)A.width(A[0].width),A.height(A[0].height);else{var C=new Image;C.src=A[0].src,A.width(C.width),A.height(C.height)}var D=A.clone().removeAttr("id").
12
+ css(z).show();D.width(A.width()),D.height(A.height()),A.after(D).hide()}else D=A.css(z).show(),B=!1,d.shade===null&&(d.shade=!0);t(D,d.boxWidth,d.boxHeight);var E=D.width(),F=D.height(),G=a("<div />").width(E).height(F).addClass(j("holder")).css({position:"relative",backgroundColor:d.bgColor}).insertAfter(A).append(D);d.addClass&&G.addClass(d.addClass);var H=a("<div />"),I=a("<div />").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),J=a("<div />").width("100%").height("100%").css("zIndex",320),K=a("<div />").css({position:"absolute",zIndex:600}).dblclick(function(){var a=_.getFixed();d.onDblClick.call(bs,a)}).insertBefore(D).append(I,J);B&&(H=a("<img />").attr("src",D.attr("src")).css(z).width(E).height(F),I.append(H)),h&&K.css({overflowY:"hidden"});var L=d.boundary,M=y().width(E+L*2).height(F+L*2).css({position:"absolute",top:i(-L),left:i(-L),zIndex:290}).mousedown(w),N=d.bgColor,O=d.bgOpacity,P,Q,R,S,T,U,V=!0,W,X,Y;e=l(D);var Z=function(){function a(){var a={},b=["touchstart"
13
+ ,"touchmove","touchend"],c=document.createElement("div"),d;try{for(d=0;d<b.length;d++){var e=b[d];e="on"+e;var f=e in c;f||(c.setAttribute(e,"return;"),f=typeof c[e]=="function"),a[b[d]]=f}return a.touchstart&&a.touchend&&a.touchmove}catch(g){return!1}}function b(){return d.touchSupport===!0||d.touchSupport===!1?d.touchSupport:a()}return{createDragger:function(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=l(D),W=!0,o(a,m(Z.cfilter(b)),!0),b.stopPropagation(),b.preventDefault(),!1)}},newSelection:function(a){return w(Z.cfilter(a))},cfilter:function(a){return a.pageX=a.originalEvent.changedTouches[0].pageX,a.pageY=a.originalEvent.changedTouches[0].pageY,a},isSupported:a,support:b()}}(),_=function(){function h(d){d=n(d),c=a=d[0],e=b=d[1]}function i(a){a=n(a),f=a[0]-c,g=a[1]-e,c=a[0],e=a[1]}function j(){return[f,g]}function k(d){var f=d[0],g=d[1];0>a+f&&(f-=f+a),0>b+g&&(g-=g+b),F<e+g&&(g+=F-(e+g)),E<c+f&&(f+=E-(c+f)),a+=f,c+=f,b+=g,e+=g}function l(a){var b=m();switch(a){case"ne":return[
14
+ b.x2,b.y];case"nw":return[b.x,b.y];case"se":return[b.x2,b.y2];case"sw":return[b.x,b.y2]}}function m(){if(!d.aspectRatio)return p();var f=d.aspectRatio,g=d.minSize[0]/T,h=d.maxSize[0]/T,i=d.maxSize[1]/U,j=c-a,k=e-b,l=Math.abs(j),m=Math.abs(k),n=l/m,r,s,t,u;return h===0&&(h=E*10),i===0&&(i=F*10),n<f?(s=e,t=m*f,r=j<0?a-t:t+a,r<0?(r=0,u=Math.abs((r-a)/f),s=k<0?b-u:u+b):r>E&&(r=E,u=Math.abs((r-a)/f),s=k<0?b-u:u+b)):(r=c,u=l/f,s=k<0?b-u:b+u,s<0?(s=0,t=Math.abs((s-b)*f),r=j<0?a-t:t+a):s>F&&(s=F,t=Math.abs(s-b)*f,r=j<0?a-t:t+a)),r>a?(r-a<g?r=a+g:r-a>h&&(r=a+h),s>b?s=b+(r-a)/f:s=b-(r-a)/f):r<a&&(a-r<g?r=a-g:a-r>h&&(r=a-h),s>b?s=b+(a-r)/f:s=b-(a-r)/f),r<0?(a-=r,r=0):r>E&&(a-=r-E,r=E),s<0?(b-=s,s=0):s>F&&(b-=s-F,s=F),q(o(a,b,r,s))}function n(a){return a[0]<0&&(a[0]=0),a[1]<0&&(a[1]=0),a[0]>E&&(a[0]=E),a[1]>F&&(a[1]=F),[Math.round(a[0]),Math.round(a[1])]}function o(a,b,c,d){var e=a,f=c,g=b,h=d;return c<a&&(e=c,f=a),d<b&&(g=d,h=b),[e,g,f,h]}function p(){var d=c-a,f=e-b,g;return P&&Math.abs(d)>P&&(c=d>0?a+P:a-P),Q&&Math.abs
15
+ (f)>Q&&(e=f>0?b+Q:b-Q),S/U&&Math.abs(f)<S/U&&(e=f>0?b+S/U:b-S/U),R/T&&Math.abs(d)<R/T&&(c=d>0?a+R/T:a-R/T),a<0&&(c-=a,a-=a),b<0&&(e-=b,b-=b),c<0&&(a-=c,c-=c),e<0&&(b-=e,e-=e),c>E&&(g=c-E,a-=g,c-=g),e>F&&(g=e-F,b-=g,e-=g),a>E&&(g=a-F,e-=g,b-=g),b>F&&(g=b-F,e-=g,b-=g),q(o(a,b,c,e))}function q(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var a=0,b=0,c=0,e=0,f,g;return{flipCoords:o,setPressed:h,setCurrent:i,getOffset:j,moveOffset:k,getCorner:l,getFixed:m}}(),ba=function(){function f(a,b){e.left.css({height:i(b)}),e.right.css({height:i(b)})}function g(){return h(_.getFixed())}function h(a){e.top.css({left:i(a.x),width:i(a.w),height:i(a.y)}),e.bottom.css({top:i(a.y2),left:i(a.x),width:i(a.w),height:i(F-a.y2)}),e.right.css({left:i(a.x2),width:i(E-a.x2)}),e.left.css({width:i(a.x)})}function j(){return a("<div />").css({position:"absolute",backgroundColor:d.shadeColor||d.bgColor}).appendTo(c)}function k(){b||(b=!0,c.insertBefore(D),g(),bb.setBgOpacity(1,0,1),H.hide(),l(d.shadeColor||d.bgColor,1),bb.
16
+ isAwake()?n(d.bgOpacity,1):n(1,1))}function l(a,b){bq(p(),a,b)}function m(){b&&(c.remove(),H.show(),b=!1,bb.isAwake()?bb.setBgOpacity(d.bgOpacity,1,1):(bb.setBgOpacity(1,1,1),bb.disableHandles()),bq(G,0,1))}function n(a,e){b&&(d.bgFade&&!e?c.animate({opacity:1-a},{queue:!1,duration:d.fadeTime}):c.css({opacity:1-a}))}function o(){d.shade?k():m(),bb.isAwake()&&n(d.bgOpacity)}function p(){return c.children()}var b=!1,c=a("<div />").css({position:"absolute",zIndex:240,opacity:0}),e={top:j(),left:j().height(F),right:j().height(F),bottom:j()};return{update:g,updateRaw:h,getShades:p,setBgColor:l,enable:k,disable:m,resize:f,refresh:o,opacity:n}}(),bb=function(){function k(b){var c=a("<div />").css({position:"absolute",opacity:d.borderOpacity}).addClass(j(b));return I.append(c),c}function l(b,c){var d=a("<div />").mousedown(s(b)).css({cursor:b+"-resize",position:"absolute",zIndex:c}).addClass("ord-"+b);return Z.support&&d.bind("touchstart.jcrop",Z.createDragger(b)),J.append(d),d}function m(a){var b=d.handleSize,e=l(a,c++
17
+ ).css({opacity:d.handleOpacity}).addClass(j("handle"));return b&&e.width(b).height(b),e}function n(a){return l(a,c++).addClass("jcrop-dragbar")}function o(a){var b;for(b=0;b<a.length;b++)g[a[b]]=n(a[b])}function p(a){var b,c;for(c=0;c<a.length;c++){switch(a[c]){case"n":b="hline";break;case"s":b="hline bottom";break;case"e":b="vline right";break;case"w":b="vline"}e[a[c]]=k(b)}}function q(a){var b;for(b=0;b<a.length;b++)f[a[b]]=m(a[b])}function r(a,b){d.shade||H.css({top:i(-b),left:i(-a)}),K.css({top:i(b),left:i(a)})}function t(a,b){K.width(Math.round(a)).height(Math.round(b))}function v(){var a=_.getFixed();_.setPressed([a.x,a.y]),_.setCurrent([a.x2,a.y2]),w()}function w(a){if(b)return x(a)}function x(a){var c=_.getFixed();t(c.w,c.h),r(c.x,c.y),d.shade&&ba.updateRaw(c),b||A(),a?d.onSelect.call(bs,u(c)):d.onChange.call(bs,u(c))}function z(a,c,e){if(!b&&!c)return;d.bgFade&&!e?D.animate({opacity:a},{queue:!1,duration:d.fadeTime}):D.css("opacity",a)}function A(){K.show(),d.shade?ba.opacity(O):z(O,!0),b=!0}function B
18
+ (){F(),K.hide(),d.shade?ba.opacity(1):z(1),b=!1,d.onRelease.call(bs)}function C(){h&&J.show()}function E(){h=!0;if(d.allowResize)return J.show(),!0}function F(){h=!1,J.hide()}function G(a){a?(X=!0,F()):(X=!1,E())}function L(){G(!1),v()}var b,c=370,e={},f={},g={},h=!1;d.dragEdges&&a.isArray(d.createDragbars)&&o(d.createDragbars),a.isArray(d.createHandles)&&q(d.createHandles),d.drawBorders&&a.isArray(d.createBorders)&&p(d.createBorders),a(document).bind("touchstart.jcrop-ios",function(b){a(b.currentTarget).hasClass("jcrop-tracker")&&b.stopPropagation()});var M=y().mousedown(s("move")).css({cursor:"move",position:"absolute",zIndex:360});return Z.support&&M.bind("touchstart.jcrop",Z.createDragger("move")),I.append(M),F(),{updateVisible:w,update:x,release:B,refresh:v,isAwake:function(){return b},setCursor:function(a){M.css("cursor",a)},enableHandles:E,enableOnly:function(){h=!0},showHandles:C,disableHandles:F,animMode:G,setBgOpacity:z,done:L}}(),bc=function(){function f(b){M.css({zIndex:450}),b?a(document).bind("touchmove.jcrop"
19
+ ,k).bind("touchend.jcrop",l):e&&a(document).bind("mousemove.jcrop",h).bind("mouseup.jcrop",i)}function g(){M.css({zIndex:290}),a(document).unbind(".jcrop")}function h(a){return b(m(a)),!1}function i(a){return a.preventDefault(),a.stopPropagation(),W&&(W=!1,c(m(a)),bb.isAwake()&&d.onSelect.call(bs,u(_.getFixed())),g(),b=function(){},c=function(){}),!1}function j(a,d,e){return W=!0,b=a,c=d,f(e),!1}function k(a){return b(m(Z.cfilter(a))),!1}function l(a){return i(Z.cfilter(a))}function n(a){M.css("cursor",a)}var b=function(){},c=function(){},e=d.trackDocument;return e||M.mousemove(h).mouseup(i).mouseout(i),D.before(M),{activateHandlers:j,setCursor:n}}(),bd=function(){function e(){d.keySupport&&(b.show(),b.focus())}function f(a){b.hide()}function g(a,b,c){d.allowMove&&(_.moveOffset([b,c]),bb.updateVisible(!0)),a.preventDefault(),a.stopPropagation()}function i(a){if(a.ctrlKey||a.metaKey)return!0;Y=a.shiftKey?!0:!1;var b=Y?10:1;switch(a.keyCode){case 37:g(a,-b,0);break;case 39:g(a,b,0);break;case 38:g(a,0,-b);break;
20
+ case 40:g(a,0,b);break;case 27:d.allowSelect&&bb.release();break;case 9:return!0}return!1}var b=a('<input type="radio" />').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),c=a("<div />").css({position:"absolute",overflow:"hidden"}).append(b);return d.keySupport&&(b.keydown(i).blur(f),h||!d.fixedSupport?(b.css({position:"absolute",left:"-20px"}),c.append(b).insertBefore(D)):b.insertBefore(D)),{watchKeys:e}}();Z.support&&M.bind("touchstart.jcrop",Z.newSelection),J.hide(),br(!0);var bs={setImage:bp,animateTo:bf,setSelect:bg,setOptions:bk,tellSelect:bi,tellScaled:bj,setClass:be,disable:bl,enable:bm,cancel:bn,release:bb.release,destroy:bo,focus:bd.watchKeys,getBounds:function(){return[E*T,F*U]},getWidgetSize:function(){return[E,F]},getScaleFactor:function(){return[T,U]},getOptions:function(){return d},ui:{holder:G,selection:K}};return g&&G.bind("selectstart",function(){return!1}),A.data("Jcrop",bs),bs},a.fn.Jcrop=function(b,c){var d;return this.each(function(){if(a(this).data("Jcrop")){if(
21
+ b==="api")return a(this).data("Jcrop");a(this).data("Jcrop").setOptions(b)}else this.tagName=="IMG"?a.Jcrop.Loader(this,function(){a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d)}):(a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d))}),this},a.Jcrop.Loader=function(b,c,d){function g(){f.complete?(e.unbind(".jcloader"),a.isFunction(c)&&c.call(f)):window.setTimeout(g,50)}var e=a(b),f=e[0];e.bind("load.jcloader",g).bind("error.jcloader",function(b){e.unbind(".jcloader"),a.isFunction(d)&&d.call(f)}),f.complete&&a.isFunction(c)&&(e.unbind(".jcloader"),c.call(f))},a.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges
22
  :!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}})(jQuery);
lang/cpt_lang-de_DE.po CHANGED
@@ -1,235 +1,235 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Crop-Post-Thumbnails\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-12-03 14:55+0100\n"
6
- "PO-Revision-Date: 2012-12-03 14:55+0100\n"
7
- "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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
- "X-Poedit-KeywordsList: __;_e;esc_attr_e;esc_html_e;esc_html__\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: ..\n"
15
-
16
- #: ../crop-thumbnails.php:34
17
- msgid "Crop your thumbnails, the easy way."
18
- msgstr "Zuschnitt ihrer Artikelbilder - einfach gemacht."
19
-
20
- #: ../functions/editor.php:23
21
- #: ../functions/editor.php:43
22
- msgid "An error happend!"
23
- msgstr "Es ist ein Fehler aufgetretten!"
24
-
25
- #: ../functions/editor.php:39
26
- msgid "No featured Image set for this post until now."
27
- msgstr "Bisher ist kein Artikelbild gesetzt worden."
28
-
29
- #: ../functions/editor.php:75
30
- #: ../functions/editor.php:187
31
- msgid "Cropping is disabled for this post-type."
32
- msgstr "Das Zuschneiden ist für diesen Eintragstyp deaktiviert."
33
-
34
- #: ../functions/editor.php:77
35
- msgid "No images in this post yet. You have to upload some via upload dialog."
36
- msgstr "Zu diesem Eintrag wurden bisher keine Bilder hinzugefügt."
37
-
38
- #: ../functions/editor.php:98
39
- msgid "Choose the image you want to crop."
40
- msgstr "Wählen Sie das Bild aus, das Sie zuschneiden wollen."
41
-
42
- #: ../functions/editor.php:104
43
- msgid "Post Thumbnail"
44
- msgstr "Artikel-Vorschaubild"
45
-
46
- #: ../functions/editor.php:104
47
- #, php-format
48
- msgid "Image %d"
49
- msgstr "Bild %d"
50
-
51
- #: ../functions/editor.php:164
52
- msgid "bug - this case shouldnt be happend"
53
- msgstr "BUG - dieser Fall hätte nie eintretten drüfen - Plugin-Autor benachrichtigen."
54
-
55
- #: ../functions/editor.php:165
56
- msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
57
- msgstr "Warung: das Original-Bild ist zu klein um für diese Thumbnail-Größe es in guter Qualität zuzuschneiden."
58
-
59
- #: ../functions/editor.php:166
60
- msgid "First, select one image. Then, click once again."
61
- msgstr "Erst ein Bild auswählen, danach erneut probieren."
62
-
63
- #: ../functions/editor.php:192
64
- msgid "back to image-list"
65
- msgstr "Zurück zur Bild-Übersicht"
66
-
67
- #: ../functions/editor.php:193
68
- msgid "Please wait until the Images are cropped."
69
- msgstr "Bitte warten Sie bis die Bilder zugeschnitten wurden."
70
-
71
- #: ../functions/editor.php:196
72
- msgid "Raw"
73
- msgstr "Original-Bild"
74
-
75
- #: ../functions/editor.php:196
76
- #: ../functions/editor.php:237
77
- msgid "pixel"
78
- msgstr "Pixel"
79
-
80
- #: ../functions/editor.php:198
81
- msgid "save crop"
82
- msgstr "Zuschnitt übernehmen"
83
-
84
- #: ../functions/editor.php:199
85
- msgid "Quick-Instructions"
86
- msgstr "Schnell-Anleitung"
87
-
88
- #: ../functions/editor.php:201
89
- msgid "Step 1: Choose an image from the right."
90
- msgstr "Schritt 1: Wählen Sie ein Bild von der rechten Seite."
91
-
92
- #: ../functions/editor.php:202
93
- msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
94
- msgstr "Schritt 2: Benutzen Sie die Maus um die Größe des Rechtecks im oberen Bild zu ändern."
95
-
96
- #: ../functions/editor.php:203
97
- msgid "Step 3: Click on \"save crop\"."
98
- msgstr "Schritt 3: Klicken Sie auf \"Zuschnitt übernehmen\"."
99
-
100
- #: ../functions/editor.php:208
101
- msgid "select images with same ratio at once"
102
- msgstr "bei gleichem Seitenverhältnis gemeinsam auswählen"
103
-
104
- #: ../functions/editor.php:209
105
- msgid "deselect all"
106
- msgstr "nichts auswählen"
107
-
108
- #: ../functions/editor.php:221
109
- msgid "cropped"
110
- msgstr "zugeschnitten"
111
-
112
- #: ../functions/editor.php:231
113
- msgid "Original image to small for good crop-quality!"
114
- msgstr "Original-Bild ist zu klein für guten Bildzuschnitt!"
115
-
116
- #: ../functions/editor.php:237
117
- msgid "Dimensions:"
118
- msgstr "Größe:"
119
-
120
- #: ../functions/editor.php:238
121
- msgid "Ratio:"
122
- msgstr "Seitenverhältnis:"
123
-
124
- #: ../functions/editor.php:421
125
- msgid "Crop Thumbnails"
126
- msgstr "Bilder Zuschneiden"
127
-
128
- #: ../functions/editor.php:425
129
- msgid "Crop Featured Image"
130
- msgstr "Artikelbild zuschneiden"
131
-
132
- #: ../functions/editor.php:439
133
- msgid "Crop Thumbnail"
134
- msgstr "Bild zuschneiden"
135
-
136
- #: ../functions/save.php:95
137
- #, php-format
138
- msgid "Cant generate filesize \"%s\"."
139
- msgstr "Cant generate filesize \"%s\"."
140
-
141
- #: ../functions/save.php:102
142
- msgid "Cant copy temporary file to media-library."
143
- msgstr "Kopieren vom temporären Verzeichnis in die Mediathek fehlgeschlagen."
144
-
145
- #: ../functions/save.php:106
146
- msgid "Cant delete temporary file."
147
- msgstr "Löschen der temporären Datei fehlgeschlagen."
148
-
149
- #: ../functions/save.php:172
150
- msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
151
- msgstr "Fehler: Sicherheitsüberprüfung fehlgeschlagen (vielleicht eine Zeitüberschreitung - bitte versuchen Sie es noch einmal)."
152
-
153
- #: ../functions/save.php:176
154
- msgid "ERROR: Submitted data are not complete."
155
- msgstr "Fehler: Übermittelte Daten sind nicht vollständig."
156
-
157
- #: ../functions/save.php:184
158
- msgid "A cropping with this dimensions on these Image ist not possible."
159
- msgstr "Das Zuschneiden mit diesen Einstellungen ist bei diesem Bild nicht möglich."
160
-
161
- #: ../functions/save.php:195
162
- msgid "ERROR: Can`t find original Image in Database!"
163
- msgstr "Fehler: Konnte die Original Bild nicht in der Datenbank finden!"
164
-
165
- #: ../functions/save.php:198
166
- msgid "ERROR: Can`t find original Imagefile!"
167
- msgstr "Fehler: Konnte die Original-Bilddatei nicht finden!"
168
-
169
- #: ../functions/save.php:201
170
- msgid "ERROR: Can`t find original Image-Metadata!"
171
- msgstr "Fehler: Konnte Original-Bild-Metadaten nicht finden!"
172
-
173
- #: ../functions/settings.php:16
174
- #: ../functions/settings.php:30
175
- msgid "Settings"
176
- msgstr "Einstellungen"
177
-
178
- #: ../functions/settings.php:23
179
- msgid "Crop Post Thumbnail Page"
180
- msgstr "Crop-Post-Thumbnail Seite"
181
-
182
- #: ../functions/settings.php:35
183
- msgid "Save Changes"
184
- msgstr "Einstellungen speichern"
185
-
186
- #: ../functions/settings.php:39
187
- msgid "Support the plugin-author"
188
- msgstr "Unterstützen Sie den Plugin Entwickler"
189
-
190
- #: ../functions/settings.php:40
191
- msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
192
- msgstr "Sie können den Entwickler unterstützen <br />(und ihn so wissen lassen, dass sie dieses Plugin lieben) <br />indem sie ihm eine Paypal-Spende zukommen lassen. <br />Vielen Dank!"
193
-
194
- #: ../functions/settings.php:60
195
- msgid "Sizes and Posttypes"
196
- msgstr "Größen und Eintragstypen"
197
-
198
- #: ../functions/settings.php:61
199
- msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
200
- msgstr "Wählen sie die Bildgrößen die ausgeblendet werden sollen. Wählen Sie einen Eintragstyp um das Zuschneiden in diesen Einträge komplett zu verhindern."
201
-
202
- #: ../functions/settings.php:66
203
- msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
204
- msgstr "Crop Thumbnails wurde erstellt um das Zuschneiden von Bildern für den Benutzer zu erleichtern. Oft muss der Nutzer nur eine Bildgröße zuschneiden, abhängig vom Typ des Eintrags. Das System (Wordpress) wird aber immer alle größen erstellen. Hier können Sie auswählen für welche Eintragstypen welche Bildgrößen in der Plugin-Oberfläche angezeigt werden sollen."
205
-
206
- #: ../functions/settings.php:67
207
- msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
208
- msgstr "Crop Thumbnails wird nur Bilder anzeigen die einen Zuschnitt besitzen. Bildgrößen ohne Zuschnitt werden immer ausgeblendet."
209
-
210
- #~ msgid "Crop Thumbnails - Settings"
211
- #~ msgstr "Crop Thumbnails - Einstellungen"
212
- #~ msgid ""
213
- #~ "Wrong ratio!<br \\>OK - release images selected so far.<br \\>Cancel - "
214
- #~ "keep selected images so far."
215
- #~ msgstr ""
216
- #~ "Falsches Seitenverhältnis!<br \\>OK - bisher gewählte Bilder abwählen<br "
217
- #~ "\\>Abbrechen - bisher gewählte Bilder belassen."
218
- #~ msgid ""
219
- #~ "Hint: If you have one image selected, you can click on \"select images "
220
- #~ "with same ratio\", to select all with the ratio of these image."
221
- #~ msgstr ""
222
- #~ "Tipp: Wenn Sie ein Bild ausgewählt haben, und auf \"alle Bilder mit "
223
- #~ "diesem Seitenverhältnis auswählen\" klicken, werden automatisch alle "
224
- #~ "Einträgen mit diesem Seitenverhältnis ausgewählt."
225
- #~ msgid ""
226
- #~ "Choose the post-types you want to show the crop-editor and define what "
227
- #~ "sizes the editor should be working on. <strong>Only cropped image sizes "
228
- #~ "will be showing.</strong>"
229
- #~ msgstr ""
230
- #~ "Wählen Sie die Eintragstypen die sie im Zuschnitt-Editor verwenden "
231
- #~ "wollen, und wählen sie die Größen mit denen der Editor arbeiten soll. "
232
- #~ "<strong>Nur zugeschnittene Bildgrößen sind sichtbar.</strong>"
233
- #~ msgid "Wrong ratio!"
234
- #~ msgstr "Falsches Seitenverhältnis"
235
-
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Crop-Post-Thumbnails\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-12-03 14:55+0100\n"
6
+ "PO-Revision-Date: 2012-12-03 14:55+0100\n"
7
+ "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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
+ "X-Poedit-KeywordsList: __;_e;esc_attr_e;esc_html_e;esc_html__\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SearchPath-0: ..\n"
15
+
16
+ #: ../crop-thumbnails.php:34
17
+ msgid "Crop your thumbnails, the easy way."
18
+ msgstr "Zuschnitt ihrer Artikelbilder - einfach gemacht."
19
+
20
+ #: ../functions/editor.php:23
21
+ #: ../functions/editor.php:43
22
+ msgid "An error happend!"
23
+ msgstr "Es ist ein Fehler aufgetretten!"
24
+
25
+ #: ../functions/editor.php:39
26
+ msgid "No featured Image set for this post until now."
27
+ msgstr "Bisher ist kein Artikelbild gesetzt worden."
28
+
29
+ #: ../functions/editor.php:75
30
+ #: ../functions/editor.php:187
31
+ msgid "Cropping is disabled for this post-type."
32
+ msgstr "Das Zuschneiden ist für diesen Eintragstyp deaktiviert."
33
+
34
+ #: ../functions/editor.php:77
35
+ msgid "No images in this post yet. You have to upload some via upload dialog."
36
+ msgstr "Zu diesem Eintrag wurden bisher keine Bilder hinzugefügt."
37
+
38
+ #: ../functions/editor.php:98
39
+ msgid "Choose the image you want to crop."
40
+ msgstr "Wählen Sie das Bild aus, das Sie zuschneiden wollen."
41
+
42
+ #: ../functions/editor.php:104
43
+ msgid "Post Thumbnail"
44
+ msgstr "Artikel-Vorschaubild"
45
+
46
+ #: ../functions/editor.php:104
47
+ #, php-format
48
+ msgid "Image %d"
49
+ msgstr "Bild %d"
50
+
51
+ #: ../functions/editor.php:164
52
+ msgid "bug - this case shouldnt be happend"
53
+ msgstr "BUG - dieser Fall hätte nie eintretten drüfen - Plugin-Autor benachrichtigen."
54
+
55
+ #: ../functions/editor.php:165
56
+ msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
57
+ msgstr "Warung: das Original-Bild ist zu klein um für diese Thumbnail-Größe es in guter Qualität zuzuschneiden."
58
+
59
+ #: ../functions/editor.php:166
60
+ msgid "First, select one image. Then, click once again."
61
+ msgstr "Erst ein Bild auswählen, danach erneut probieren."
62
+
63
+ #: ../functions/editor.php:192
64
+ msgid "back to image-list"
65
+ msgstr "Zurück zur Bild-Übersicht"
66
+
67
+ #: ../functions/editor.php:193
68
+ msgid "Please wait until the Images are cropped."
69
+ msgstr "Bitte warten Sie bis die Bilder zugeschnitten wurden."
70
+
71
+ #: ../functions/editor.php:196
72
+ msgid "Raw"
73
+ msgstr "Original-Bild"
74
+
75
+ #: ../functions/editor.php:196
76
+ #: ../functions/editor.php:237
77
+ msgid "pixel"
78
+ msgstr "Pixel"
79
+
80
+ #: ../functions/editor.php:198
81
+ msgid "save crop"
82
+ msgstr "Zuschnitt übernehmen"
83
+
84
+ #: ../functions/editor.php:199
85
+ msgid "Quick-Instructions"
86
+ msgstr "Schnell-Anleitung"
87
+
88
+ #: ../functions/editor.php:201
89
+ msgid "Step 1: Choose an image from the right."
90
+ msgstr "Schritt 1: Wählen Sie ein Bild von der rechten Seite."
91
+
92
+ #: ../functions/editor.php:202
93
+ msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
94
+ msgstr "Schritt 2: Benutzen Sie die Maus um die Größe des Rechtecks im oberen Bild zu ändern."
95
+
96
+ #: ../functions/editor.php:203
97
+ msgid "Step 3: Click on \"save crop\"."
98
+ msgstr "Schritt 3: Klicken Sie auf \"Zuschnitt übernehmen\"."
99
+
100
+ #: ../functions/editor.php:208
101
+ msgid "select images with same ratio at once"
102
+ msgstr "bei gleichem Seitenverhältnis gemeinsam auswählen"
103
+
104
+ #: ../functions/editor.php:209
105
+ msgid "deselect all"
106
+ msgstr "nichts auswählen"
107
+
108
+ #: ../functions/editor.php:221
109
+ msgid "cropped"
110
+ msgstr "zugeschnitten"
111
+
112
+ #: ../functions/editor.php:231
113
+ msgid "Original image to small for good crop-quality!"
114
+ msgstr "Original-Bild ist zu klein für guten Bildzuschnitt!"
115
+
116
+ #: ../functions/editor.php:237
117
+ msgid "Dimensions:"
118
+ msgstr "Größe:"
119
+
120
+ #: ../functions/editor.php:238
121
+ msgid "Ratio:"
122
+ msgstr "Seitenverhältnis:"
123
+
124
+ #: ../functions/editor.php:421
125
+ msgid "Crop Thumbnails"
126
+ msgstr "Bilder Zuschneiden"
127
+
128
+ #: ../functions/editor.php:425
129
+ msgid "Crop Featured Image"
130
+ msgstr "Artikelbild zuschneiden"
131
+
132
+ #: ../functions/editor.php:439
133
+ msgid "Crop Thumbnail"
134
+ msgstr "Bild zuschneiden"
135
+
136
+ #: ../functions/save.php:95
137
+ #, php-format
138
+ msgid "Cant generate filesize \"%s\"."
139
+ msgstr "Cant generate filesize \"%s\"."
140
+
141
+ #: ../functions/save.php:102
142
+ msgid "Cant copy temporary file to media-library."
143
+ msgstr "Kopieren vom temporären Verzeichnis in die Mediathek fehlgeschlagen."
144
+
145
+ #: ../functions/save.php:106
146
+ msgid "Cant delete temporary file."
147
+ msgstr "Löschen der temporären Datei fehlgeschlagen."
148
+
149
+ #: ../functions/save.php:172
150
+ msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
151
+ msgstr "Fehler: Sicherheitsüberprüfung fehlgeschlagen (vielleicht eine Zeitüberschreitung - bitte versuchen Sie es noch einmal)."
152
+
153
+ #: ../functions/save.php:176
154
+ msgid "ERROR: Submitted data are not complete."
155
+ msgstr "Fehler: Übermittelte Daten sind nicht vollständig."
156
+
157
+ #: ../functions/save.php:184
158
+ msgid "A cropping with this dimensions on these Image ist not possible."
159
+ msgstr "Das Zuschneiden mit diesen Einstellungen ist bei diesem Bild nicht möglich."
160
+
161
+ #: ../functions/save.php:195
162
+ msgid "ERROR: Can`t find original Image in Database!"
163
+ msgstr "Fehler: Konnte die Original Bild nicht in der Datenbank finden!"
164
+
165
+ #: ../functions/save.php:198
166
+ msgid "ERROR: Can`t find original Imagefile!"
167
+ msgstr "Fehler: Konnte die Original-Bilddatei nicht finden!"
168
+
169
+ #: ../functions/save.php:201
170
+ msgid "ERROR: Can`t find original Image-Metadata!"
171
+ msgstr "Fehler: Konnte Original-Bild-Metadaten nicht finden!"
172
+
173
+ #: ../functions/settings.php:16
174
+ #: ../functions/settings.php:30
175
+ msgid "Settings"
176
+ msgstr "Einstellungen"
177
+
178
+ #: ../functions/settings.php:23
179
+ msgid "Crop Post Thumbnail Page"
180
+ msgstr "Crop-Post-Thumbnail Seite"
181
+
182
+ #: ../functions/settings.php:35
183
+ msgid "Save Changes"
184
+ msgstr "Einstellungen speichern"
185
+
186
+ #: ../functions/settings.php:39
187
+ msgid "Support the plugin-author"
188
+ msgstr "Unterstützen Sie den Plugin Entwickler"
189
+
190
+ #: ../functions/settings.php:40
191
+ msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
192
+ msgstr "Sie können den Entwickler unterstützen <br />(und ihn so wissen lassen, dass sie dieses Plugin lieben) <br />indem sie ihm eine Paypal-Spende zukommen lassen. <br />Vielen Dank!"
193
+
194
+ #: ../functions/settings.php:60
195
+ msgid "Sizes and Posttypes"
196
+ msgstr "Größen und Eintragstypen"
197
+
198
+ #: ../functions/settings.php:61
199
+ msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
200
+ msgstr "Wählen sie die Bildgrößen die ausgeblendet werden sollen. Wählen Sie einen Eintragstyp um das Zuschneiden in diesen Einträge komplett zu verhindern."
201
+
202
+ #: ../functions/settings.php:66
203
+ msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
204
+ msgstr "Crop Thumbnails wurde erstellt um das Zuschneiden von Bildern für den Benutzer zu erleichtern. Oft muss der Nutzer nur eine Bildgröße zuschneiden, abhängig vom Typ des Eintrags. Das System (Wordpress) wird aber immer alle größen erstellen. Hier können Sie auswählen für welche Eintragstypen welche Bildgrößen in der Plugin-Oberfläche angezeigt werden sollen."
205
+
206
+ #: ../functions/settings.php:67
207
+ msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
208
+ msgstr "Crop Thumbnails wird nur Bilder anzeigen die einen Zuschnitt besitzen. Bildgrößen ohne Zuschnitt werden immer ausgeblendet."
209
+
210
+ #~ msgid "Crop Thumbnails - Settings"
211
+ #~ msgstr "Crop Thumbnails - Einstellungen"
212
+ #~ msgid ""
213
+ #~ "Wrong ratio!<br \\>OK - release images selected so far.<br \\>Cancel - "
214
+ #~ "keep selected images so far."
215
+ #~ msgstr ""
216
+ #~ "Falsches Seitenverhältnis!<br \\>OK - bisher gewählte Bilder abwählen<br "
217
+ #~ "\\>Abbrechen - bisher gewählte Bilder belassen."
218
+ #~ msgid ""
219
+ #~ "Hint: If you have one image selected, you can click on \"select images "
220
+ #~ "with same ratio\", to select all with the ratio of these image."
221
+ #~ msgstr ""
222
+ #~ "Tipp: Wenn Sie ein Bild ausgewählt haben, und auf \"alle Bilder mit "
223
+ #~ "diesem Seitenverhältnis auswählen\" klicken, werden automatisch alle "
224
+ #~ "Einträgen mit diesem Seitenverhältnis ausgewählt."
225
+ #~ msgid ""
226
+ #~ "Choose the post-types you want to show the crop-editor and define what "
227
+ #~ "sizes the editor should be working on. <strong>Only cropped image sizes "
228
+ #~ "will be showing.</strong>"
229
+ #~ msgstr ""
230
+ #~ "Wählen Sie die Eintragstypen die sie im Zuschnitt-Editor verwenden "
231
+ #~ "wollen, und wählen sie die Größen mit denen der Editor arbeiten soll. "
232
+ #~ "<strong>Nur zugeschnittene Bildgrößen sind sichtbar.</strong>"
233
+ #~ msgid "Wrong ratio!"
234
+ #~ msgstr "Falsches Seitenverhältnis"
235
+
lang/cpt_lang-default.po CHANGED
@@ -1,209 +1,209 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Crop-Post-Thumbnails\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-12-03 14:35+0100\n"
6
- "PO-Revision-Date: 2012-12-03 14:54+0100\n"
7
- "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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
- "X-Poedit-KeywordsList: __;_e;esc_attr_e;esc_attr__;esc_html_e\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: ..\n"
15
-
16
- #: ../crop-thumbnails.php:35
17
- msgid "Crop your thumbnails, the easy way."
18
- msgstr ""
19
-
20
- #: ../functions/editor.php:23
21
- #: ../functions/editor.php:43
22
- msgid "An error happend!"
23
- msgstr ""
24
-
25
- #: ../functions/editor.php:39
26
- msgid "No featured Image set for this post until now."
27
- msgstr ""
28
-
29
- #: ../functions/editor.php:75
30
- #: ../functions/editor.php:187
31
- msgid "Cropping is disabled for this post-type."
32
- msgstr ""
33
-
34
- #: ../functions/editor.php:77
35
- msgid "No images in this post yet. You have to upload some via upload dialog."
36
- msgstr ""
37
-
38
- #: ../functions/editor.php:98
39
- msgid "Choose the image you want to crop."
40
- msgstr ""
41
-
42
- #: ../functions/editor.php:104
43
- msgid "Post Thumbnail"
44
- msgstr ""
45
-
46
- #: ../functions/editor.php:104
47
- #, php-format
48
- msgid "Image %d"
49
- msgstr ""
50
-
51
- #: ../functions/editor.php:164
52
- msgid "bug - this case shouldnt be happend"
53
- msgstr ""
54
-
55
- #: ../functions/editor.php:165
56
- msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
57
- msgstr ""
58
-
59
- #: ../functions/editor.php:166
60
- msgid "First, select one image. Then, click once again."
61
- msgstr ""
62
-
63
- #: ../functions/editor.php:192
64
- msgid "back to image-list"
65
- msgstr ""
66
-
67
- #: ../functions/editor.php:193
68
- msgid "Please wait until the Images are cropped."
69
- msgstr ""
70
-
71
- #: ../functions/editor.php:196
72
- msgid "Raw"
73
- msgstr ""
74
-
75
- #: ../functions/editor.php:196
76
- #: ../functions/editor.php:237
77
- msgid "pixel"
78
- msgstr ""
79
-
80
- #: ../functions/editor.php:198
81
- msgid "save crop"
82
- msgstr ""
83
-
84
- #: ../functions/editor.php:199
85
- msgid "Quick-Instructions"
86
- msgstr ""
87
-
88
- #: ../functions/editor.php:201
89
- msgid "Step 1: Choose an image from the right."
90
- msgstr ""
91
-
92
- #: ../functions/editor.php:202
93
- msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
94
- msgstr ""
95
-
96
- #: ../functions/editor.php:203
97
- msgid "Step 3: Click on \"save crop\"."
98
- msgstr ""
99
-
100
- #: ../functions/editor.php:208
101
- msgid "select images with same ratio at once"
102
- msgstr ""
103
-
104
- #: ../functions/editor.php:209
105
- msgid "deselect all"
106
- msgstr ""
107
-
108
- #: ../functions/editor.php:221
109
- msgid "cropped"
110
- msgstr ""
111
-
112
- #: ../functions/editor.php:231
113
- msgid "Original image to small for good crop-quality!"
114
- msgstr ""
115
-
116
- #: ../functions/editor.php:237
117
- msgid "Dimensions:"
118
- msgstr ""
119
-
120
- #: ../functions/editor.php:238
121
- msgid "Ratio:"
122
- msgstr ""
123
-
124
- #: ../functions/editor.php:421
125
- msgid "Crop Thumbnails"
126
- msgstr ""
127
-
128
- #: ../functions/editor.php:425
129
- msgid "Crop Featured Image"
130
- msgstr ""
131
-
132
- #: ../functions/editor.php:439
133
- msgid "Crop Thumbnail"
134
- msgstr ""
135
-
136
- #: ../functions/save.php:95
137
- #, php-format
138
- msgid "Cant generate filesize \"%s\"."
139
- msgstr ""
140
-
141
- #: ../functions/save.php:102
142
- msgid "Cant copy temporary file to media-library."
143
- msgstr ""
144
-
145
- #: ../functions/save.php:106
146
- msgid "Cant delete temporary file."
147
- msgstr ""
148
-
149
- #: ../functions/save.php:172
150
- msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
151
- msgstr ""
152
-
153
- #: ../functions/save.php:176
154
- msgid "ERROR: Submitted data are not complete."
155
- msgstr ""
156
-
157
- #: ../functions/save.php:184
158
- msgid "A cropping with this dimensions on these Image ist not possible."
159
- msgstr ""
160
-
161
- #: ../functions/save.php:195
162
- msgid "ERROR: Can`t find original Image in Database!"
163
- msgstr ""
164
-
165
- #: ../functions/save.php:198
166
- msgid "ERROR: Can`t find original Imagefile!"
167
- msgstr ""
168
-
169
- #: ../functions/save.php:201
170
- msgid "ERROR: Can`t find original Image-Metadata!"
171
- msgstr ""
172
-
173
- #: ../functions/settings.php:16
174
- #: ../functions/settings.php:30
175
- msgid "Settings"
176
- msgstr ""
177
-
178
- #: ../functions/settings.php:23
179
- msgid "Crop Post Thumbnail Page"
180
- msgstr ""
181
-
182
- #: ../functions/settings.php:35
183
- msgid "Save Changes"
184
- msgstr ""
185
-
186
- #: ../functions/settings.php:39
187
- msgid "Support the plugin-author"
188
- msgstr ""
189
-
190
- #: ../functions/settings.php:40
191
- msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
192
- msgstr ""
193
-
194
- #: ../functions/settings.php:60
195
- msgid "Sizes and Posttypes"
196
- msgstr ""
197
-
198
- #: ../functions/settings.php:61
199
- msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
200
- msgstr ""
201
-
202
- #: ../functions/settings.php:66
203
- msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
204
- msgstr ""
205
-
206
- #: ../functions/settings.php:67
207
- msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
208
- msgstr ""
209
-
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Crop-Post-Thumbnails\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-12-03 14:35+0100\n"
6
+ "PO-Revision-Date: 2012-12-03 14:54+0100\n"
7
+ "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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
+ "X-Poedit-KeywordsList: __;_e;esc_attr_e;esc_attr__;esc_html_e\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SearchPath-0: ..\n"
15
+
16
+ #: ../crop-thumbnails.php:35
17
+ msgid "Crop your thumbnails, the easy way."
18
+ msgstr ""
19
+
20
+ #: ../functions/editor.php:23
21
+ #: ../functions/editor.php:43
22
+ msgid "An error happend!"
23
+ msgstr ""
24
+
25
+ #: ../functions/editor.php:39
26
+ msgid "No featured Image set for this post until now."
27
+ msgstr ""
28
+
29
+ #: ../functions/editor.php:75
30
+ #: ../functions/editor.php:187
31
+ msgid "Cropping is disabled for this post-type."
32
+ msgstr ""
33
+
34
+ #: ../functions/editor.php:77
35
+ msgid "No images in this post yet. You have to upload some via upload dialog."
36
+ msgstr ""
37
+
38
+ #: ../functions/editor.php:98
39
+ msgid "Choose the image you want to crop."
40
+ msgstr ""
41
+
42
+ #: ../functions/editor.php:104
43
+ msgid "Post Thumbnail"
44
+ msgstr ""
45
+
46
+ #: ../functions/editor.php:104
47
+ #, php-format
48
+ msgid "Image %d"
49
+ msgstr ""
50
+
51
+ #: ../functions/editor.php:164
52
+ msgid "bug - this case shouldnt be happend"
53
+ msgstr ""
54
+
55
+ #: ../functions/editor.php:165
56
+ msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
57
+ msgstr ""
58
+
59
+ #: ../functions/editor.php:166
60
+ msgid "First, select one image. Then, click once again."
61
+ msgstr ""
62
+
63
+ #: ../functions/editor.php:192
64
+ msgid "back to image-list"
65
+ msgstr ""
66
+
67
+ #: ../functions/editor.php:193
68
+ msgid "Please wait until the Images are cropped."
69
+ msgstr ""
70
+
71
+ #: ../functions/editor.php:196
72
+ msgid "Raw"
73
+ msgstr ""
74
+
75
+ #: ../functions/editor.php:196
76
+ #: ../functions/editor.php:237
77
+ msgid "pixel"
78
+ msgstr ""
79
+
80
+ #: ../functions/editor.php:198
81
+ msgid "save crop"
82
+ msgstr ""
83
+
84
+ #: ../functions/editor.php:199
85
+ msgid "Quick-Instructions"
86
+ msgstr ""
87
+
88
+ #: ../functions/editor.php:201
89
+ msgid "Step 1: Choose an image from the right."
90
+ msgstr ""
91
+
92
+ #: ../functions/editor.php:202
93
+ msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
94
+ msgstr ""
95
+
96
+ #: ../functions/editor.php:203
97
+ msgid "Step 3: Click on \"save crop\"."
98
+ msgstr ""
99
+
100
+ #: ../functions/editor.php:208
101
+ msgid "select images with same ratio at once"
102
+ msgstr ""
103
+
104
+ #: ../functions/editor.php:209
105
+ msgid "deselect all"
106
+ msgstr ""
107
+
108
+ #: ../functions/editor.php:221
109
+ msgid "cropped"
110
+ msgstr ""
111
+
112
+ #: ../functions/editor.php:231
113
+ msgid "Original image to small for good crop-quality!"
114
+ msgstr ""
115
+
116
+ #: ../functions/editor.php:237
117
+ msgid "Dimensions:"
118
+ msgstr ""
119
+
120
+ #: ../functions/editor.php:238
121
+ msgid "Ratio:"
122
+ msgstr ""
123
+
124
+ #: ../functions/editor.php:421
125
+ msgid "Crop Thumbnails"
126
+ msgstr ""
127
+
128
+ #: ../functions/editor.php:425
129
+ msgid "Crop Featured Image"
130
+ msgstr ""
131
+
132
+ #: ../functions/editor.php:439
133
+ msgid "Crop Thumbnail"
134
+ msgstr ""
135
+
136
+ #: ../functions/save.php:95
137
+ #, php-format
138
+ msgid "Cant generate filesize \"%s\"."
139
+ msgstr ""
140
+
141
+ #: ../functions/save.php:102
142
+ msgid "Cant copy temporary file to media-library."
143
+ msgstr ""
144
+
145
+ #: ../functions/save.php:106
146
+ msgid "Cant delete temporary file."
147
+ msgstr ""
148
+
149
+ #: ../functions/save.php:172
150
+ msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
151
+ msgstr ""
152
+
153
+ #: ../functions/save.php:176
154
+ msgid "ERROR: Submitted data are not complete."
155
+ msgstr ""
156
+
157
+ #: ../functions/save.php:184
158
+ msgid "A cropping with this dimensions on these Image ist not possible."
159
+ msgstr ""
160
+
161
+ #: ../functions/save.php:195
162
+ msgid "ERROR: Can`t find original Image in Database!"
163
+ msgstr ""
164
+
165
+ #: ../functions/save.php:198
166
+ msgid "ERROR: Can`t find original Imagefile!"
167
+ msgstr ""
168
+
169
+ #: ../functions/save.php:201
170
+ msgid "ERROR: Can`t find original Image-Metadata!"
171
+ msgstr ""
172
+
173
+ #: ../functions/settings.php:16
174
+ #: ../functions/settings.php:30
175
+ msgid "Settings"
176
+ msgstr ""
177
+
178
+ #: ../functions/settings.php:23
179
+ msgid "Crop Post Thumbnail Page"
180
+ msgstr ""
181
+
182
+ #: ../functions/settings.php:35
183
+ msgid "Save Changes"
184
+ msgstr ""
185
+
186
+ #: ../functions/settings.php:39
187
+ msgid "Support the plugin-author"
188
+ msgstr ""
189
+
190
+ #: ../functions/settings.php:40
191
+ msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
192
+ msgstr ""
193
+
194
+ #: ../functions/settings.php:60
195
+ msgid "Sizes and Posttypes"
196
+ msgstr ""
197
+
198
+ #: ../functions/settings.php:61
199
+ msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
200
+ msgstr ""
201
+
202
+ #: ../functions/settings.php:66
203
+ msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
204
+ msgstr ""
205
+
206
+ #: ../functions/settings.php:67
207
+ msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
208
+ msgstr ""
209
+
lang/cpt_lang-pt_BR.po CHANGED
@@ -1,259 +1,259 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Crop Thumbnails v0.7.0\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-12-03 14:36+0100\n"
6
- "PO-Revision-Date: 2012-12-04 14:45+0100\n"
7
- "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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-Poedit-Language: Portuguese\n"
14
- "X-Poedit-Country: BRAZIL\n"
15
- "X-Poedit-SourceCharset: utf-8\n"
16
- "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html__;esc_attr_e;esc_attr__\n"
17
- "X-Poedit-Basepath: ../\n"
18
- "X-Textdomain-Support: yes\n"
19
- "X-Poedit-SearchPath-0: .\n"
20
-
21
- # @ default
22
- #: crop-thumbnails.php:35
23
- msgid "Crop your thumbnails, the easy way."
24
- msgstr "Cortando suas miniaturas de uma maneira mais simples"
25
-
26
- # @ cpt_lang
27
- #: functions/editor.php:23
28
- #: functions/editor.php:43
29
- msgid "An error happend!"
30
- msgstr "Ocorreu um erro!"
31
-
32
- #: functions/editor.php:39
33
- msgid "No featured Image set for this post until now."
34
- msgstr "Sem Imagem Destacada definida para este post até o momento."
35
-
36
- # @ cpt_lang
37
- #: functions/editor.php:75
38
- #: functions/editor.php:187
39
- msgid "Cropping is disabled for this post-type."
40
- msgstr "O corte está desativado para este tipo de post."
41
-
42
- # @ cpt_lang
43
- #: functions/editor.php:77
44
- msgid "No images in this post yet. You have to upload some via upload dialog."
45
- msgstr "Não há imagens neste post ainda. Você tem que carregar alguma através da caixa de diálogo de upload."
46
-
47
- # @ cpt_lang
48
- #: functions/editor.php:98
49
- msgid "Choose the image you want to crop."
50
- msgstr "Escolha a imagem que você deseja cortar."
51
-
52
- # @ cpt_lang
53
- #: functions/editor.php:104
54
- msgid "Post Thumbnail"
55
- msgstr "Publicar Miniatura"
56
-
57
- # @ cpt_lang
58
- #: functions/editor.php:104
59
- #, php-format
60
- msgid "Image %d"
61
- msgstr "Imagem %d"
62
-
63
- # @ cpt_lang
64
- #: functions/editor.php:164
65
- msgid "bug - this case shouldnt be happend"
66
- msgstr "bug - isso não devia ter acontececido"
67
-
68
- # @ cpt_lang
69
- #: functions/editor.php:165
70
- msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
71
- msgstr "Atenção: a imagem original é muito pequena para ser cortada em boa qualidade neste tamanho de miniatura."
72
-
73
- # @ cpt_lang
74
- #: functions/editor.php:166
75
- msgid "First, select one image. Then, click once again."
76
- msgstr "Primeiro, selecione uma imagem. Em seguida, clique novamente."
77
-
78
- # @ cpt_lang
79
- #: functions/editor.php:192
80
- msgid "back to image-list"
81
- msgstr "volte a lista de imagens"
82
-
83
- # @ cpt_lang
84
- #: functions/editor.php:193
85
- msgid "Please wait until the Images are cropped."
86
- msgstr "Por favor, aguarde até que as imagens sejam cortadas."
87
-
88
- # @ cpt_lang
89
- #: functions/editor.php:196
90
- msgid "Raw"
91
- msgstr "Bruta"
92
-
93
- # @ cpt_lang
94
- #: functions/editor.php:196
95
- #: functions/editor.php:237
96
- msgid "pixel"
97
- msgstr "pixel"
98
-
99
- # @ cpt_lang
100
- #: functions/editor.php:198
101
- msgid "save crop"
102
- msgstr "Cortar e Salvar"
103
-
104
- # @ cpt_lang
105
- #: functions/editor.php:199
106
- msgid "Quick-Instructions"
107
- msgstr "Instruções Rápidas"
108
-
109
- # @ cpt_lang
110
- #: functions/editor.php:201
111
- msgid "Step 1: Choose an image from the right."
112
- msgstr "Passo 1: Escolha uma imagem à direita."
113
-
114
- # @ cpt_lang
115
- #: functions/editor.php:202
116
- msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
117
- msgstr "Passo 2: Use o mouse para alterar o tamanho do retângulo na imagem acima."
118
-
119
- # @ cpt_lang
120
- #: functions/editor.php:203
121
- msgid "Step 3: Click on \"save crop\"."
122
- msgstr "Passo 3: Clique em \"Cortar e Salvar\"."
123
-
124
- # @ cpt_lang
125
- #: functions/editor.php:208
126
- msgid "select images with same ratio at once"
127
- msgstr "Selecionar imagens com mesma proporção de uma só vez"
128
-
129
- # @ cpt_lang
130
- #: functions/editor.php:209
131
- msgid "deselect all"
132
- msgstr "Desmarcar Todos"
133
-
134
- # @ cpt_lang
135
- #: functions/editor.php:221
136
- msgid "cropped"
137
- msgstr "Cortadas"
138
-
139
- # @ cpt_lang
140
- #: functions/editor.php:231
141
- msgid "Original image to small for good crop-quality!"
142
- msgstr "Imagem original muito pequena para um corte de qualidade!"
143
-
144
- # @ cpt_lang
145
- #: functions/editor.php:237
146
- msgid "Dimensions:"
147
- msgstr "Dimensões:"
148
-
149
- # @ cpt_lang
150
- #: functions/editor.php:238
151
- msgid "Ratio:"
152
- msgstr "Relação:"
153
-
154
- # @ cpt_lang
155
- #: functions/editor.php:421
156
- msgid "Crop Thumbnails"
157
- msgstr "Cortar Miniaturas"
158
-
159
- #: functions/editor.php:425
160
- msgid "Crop Featured Image"
161
- msgstr "Cortar Imagem Destacada"
162
-
163
- # @ cpt_lang
164
- #: functions/editor.php:439
165
- msgid "Crop Thumbnail"
166
- msgstr "Cortar Miniatura"
167
-
168
- # @ cpt_lang
169
- #: functions/save.php:95
170
- #, php-format
171
- msgid "Cant generate filesize \"%s\"."
172
- msgstr "Não é possível gerar o tamanho \"%s\"."
173
-
174
- # @ cpt_lang
175
- #: functions/save.php:102
176
- msgid "Cant copy temporary file to media-library."
177
- msgstr "Não é possível copiar arquivo temporário para a biblioteca de mídia."
178
-
179
- # @ cpt_lang
180
- #: functions/save.php:106
181
- msgid "Cant delete temporary file."
182
- msgstr "Não é possível excluir arquivo temporário."
183
-
184
- # @ cpt_lang
185
- #: functions/save.php:172
186
- msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
187
- msgstr "ERRO: Verificação de Segurança falhou (talvez pelo tempo limite ter sido atingido - por favor, tente novamente)."
188
-
189
- # @ cpt_lang
190
- #: functions/save.php:176
191
- msgid "ERROR: Submitted data are not complete."
192
- msgstr "ERRO: Dados enviados não estão completos."
193
-
194
- # @ cpt_lang
195
- #: functions/save.php:184
196
- msgid "A cropping with this dimensions on these Image ist not possible."
197
- msgstr "Um corte com estas dimensões sobre esta imagem não é possível."
198
-
199
- # @ cpt_lang
200
- #: functions/save.php:195
201
- msgid "ERROR: Can`t find original Image in Database!"
202
- msgstr "ERRO: Não é possível localizar a imagem original no banco de dados!"
203
-
204
- # @ cpt_lang
205
- #: functions/save.php:198
206
- msgid "ERROR: Can`t find original Imagefile!"
207
- msgstr "ERRO: Não é possível encontrar arquivo de imagem original!"
208
-
209
- # @ cpt_lang
210
- #: functions/save.php:201
211
- msgid "ERROR: Can`t find original Image-Metadata!"
212
- msgstr "ERRO: Não é possível encontrar os metadados da imagem original!"
213
-
214
- # @ cpt_lang
215
- #: functions/settings.php:16
216
- #: functions/settings.php:30
217
- msgid "Settings"
218
- msgstr "Configurações"
219
-
220
- # @ cpt_lang
221
- #: functions/settings.php:23
222
- msgid "Crop Post Thumbnail Page"
223
- msgstr "Cortar miniaturas na página do post"
224
-
225
- # @ cpt_lang
226
- #: functions/settings.php:35
227
- msgid "Save Changes"
228
- msgstr "Salvar Mudanças"
229
-
230
- # @ cpt_lang
231
- #: functions/settings.php:39
232
- msgid "Support the plugin-author"
233
- msgstr "Apoiar o autor do plugin"
234
-
235
- # @ cpt_lang
236
- #: functions/settings.php:40
237
- msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
238
- msgstr "Você pode apoiar o autor do plugin <br />(e deixá-lo saber que você ama este plugin)<br /> doando via Paypal. Muito obrigado!"
239
-
240
- # @ cpt_lang
241
- #: functions/settings.php:60
242
- msgid "Sizes and Posttypes"
243
- msgstr "Tamanhos e Tipos de Post"
244
-
245
- # @ cpt_lang
246
- #: functions/settings.php:61
247
- msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
248
- msgstr "Escolha os tamanhos de imagem que você deseja esconder. Escolha um tipo de post para evitar qualquer uso do plugin para essas entradas."
249
-
250
- # @ cpt_lang
251
- #: functions/settings.php:66
252
- msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
253
- msgstr "Crop-Thumbnails é criado para fazer recorte fácil para o usuário. Muitas vezes o utilizador necessita somente de um recorte, pois depende dele em seu post. Mas o sistema irá criar também todos os outros tamanhos. Então, aqui você pode selecionar para que as miniaturas de seu post sejam visíveis na interface do plugin."
254
-
255
- # @ cpt_lang
256
- #: functions/settings.php:67
257
- msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
258
- msgstr "Crop-Thumbnails só irá mostrar imagens cortadas - tamanhos sem cortes serão sempre escondidos."
259
-
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Crop Thumbnails v0.7.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-12-03 14:36+0100\n"
6
+ "PO-Revision-Date: 2012-12-04 14:45+0100\n"
7
+ "Last-Translator: Volkmar Kantor <volkmar.kantor@gmx.de>\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-Poedit-Language: Portuguese\n"
14
+ "X-Poedit-Country: BRAZIL\n"
15
+ "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html__;esc_attr_e;esc_attr__\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ # @ default
22
+ #: crop-thumbnails.php:35
23
+ msgid "Crop your thumbnails, the easy way."
24
+ msgstr "Cortando suas miniaturas de uma maneira mais simples"
25
+
26
+ # @ cpt_lang
27
+ #: functions/editor.php:23
28
+ #: functions/editor.php:43
29
+ msgid "An error happend!"
30
+ msgstr "Ocorreu um erro!"
31
+
32
+ #: functions/editor.php:39
33
+ msgid "No featured Image set for this post until now."
34
+ msgstr "Sem Imagem Destacada definida para este post até o momento."
35
+
36
+ # @ cpt_lang
37
+ #: functions/editor.php:75
38
+ #: functions/editor.php:187
39
+ msgid "Cropping is disabled for this post-type."
40
+ msgstr "O corte está desativado para este tipo de post."
41
+
42
+ # @ cpt_lang
43
+ #: functions/editor.php:77
44
+ msgid "No images in this post yet. You have to upload some via upload dialog."
45
+ msgstr "Não há imagens neste post ainda. Você tem que carregar alguma através da caixa de diálogo de upload."
46
+
47
+ # @ cpt_lang
48
+ #: functions/editor.php:98
49
+ msgid "Choose the image you want to crop."
50
+ msgstr "Escolha a imagem que você deseja cortar."
51
+
52
+ # @ cpt_lang
53
+ #: functions/editor.php:104
54
+ msgid "Post Thumbnail"
55
+ msgstr "Publicar Miniatura"
56
+
57
+ # @ cpt_lang
58
+ #: functions/editor.php:104
59
+ #, php-format
60
+ msgid "Image %d"
61
+ msgstr "Imagem %d"
62
+
63
+ # @ cpt_lang
64
+ #: functions/editor.php:164
65
+ msgid "bug - this case shouldnt be happend"
66
+ msgstr "bug - isso não devia ter acontececido"
67
+
68
+ # @ cpt_lang
69
+ #: functions/editor.php:165
70
+ msgid "Warning: the original image is to small to be cropped in good quality with this thumbnail-size."
71
+ msgstr "Atenção: a imagem original é muito pequena para ser cortada em boa qualidade neste tamanho de miniatura."
72
+
73
+ # @ cpt_lang
74
+ #: functions/editor.php:166
75
+ msgid "First, select one image. Then, click once again."
76
+ msgstr "Primeiro, selecione uma imagem. Em seguida, clique novamente."
77
+
78
+ # @ cpt_lang
79
+ #: functions/editor.php:192
80
+ msgid "back to image-list"
81
+ msgstr "volte a lista de imagens"
82
+
83
+ # @ cpt_lang
84
+ #: functions/editor.php:193
85
+ msgid "Please wait until the Images are cropped."
86
+ msgstr "Por favor, aguarde até que as imagens sejam cortadas."
87
+
88
+ # @ cpt_lang
89
+ #: functions/editor.php:196
90
+ msgid "Raw"
91
+ msgstr "Bruta"
92
+
93
+ # @ cpt_lang
94
+ #: functions/editor.php:196
95
+ #: functions/editor.php:237
96
+ msgid "pixel"
97
+ msgstr "pixel"
98
+
99
+ # @ cpt_lang
100
+ #: functions/editor.php:198
101
+ msgid "save crop"
102
+ msgstr "Cortar e Salvar"
103
+
104
+ # @ cpt_lang
105
+ #: functions/editor.php:199
106
+ msgid "Quick-Instructions"
107
+ msgstr "Instruções Rápidas"
108
+
109
+ # @ cpt_lang
110
+ #: functions/editor.php:201
111
+ msgid "Step 1: Choose an image from the right."
112
+ msgstr "Passo 1: Escolha uma imagem à direita."
113
+
114
+ # @ cpt_lang
115
+ #: functions/editor.php:202
116
+ msgid "Step 2: Use the mouse change the size of the rectangle on the image above."
117
+ msgstr "Passo 2: Use o mouse para alterar o tamanho do retângulo na imagem acima."
118
+
119
+ # @ cpt_lang
120
+ #: functions/editor.php:203
121
+ msgid "Step 3: Click on \"save crop\"."
122
+ msgstr "Passo 3: Clique em \"Cortar e Salvar\"."
123
+
124
+ # @ cpt_lang
125
+ #: functions/editor.php:208
126
+ msgid "select images with same ratio at once"
127
+ msgstr "Selecionar imagens com mesma proporção de uma só vez"
128
+
129
+ # @ cpt_lang
130
+ #: functions/editor.php:209
131
+ msgid "deselect all"
132
+ msgstr "Desmarcar Todos"
133
+
134
+ # @ cpt_lang
135
+ #: functions/editor.php:221
136
+ msgid "cropped"
137
+ msgstr "Cortadas"
138
+
139
+ # @ cpt_lang
140
+ #: functions/editor.php:231
141
+ msgid "Original image to small for good crop-quality!"
142
+ msgstr "Imagem original muito pequena para um corte de qualidade!"
143
+
144
+ # @ cpt_lang
145
+ #: functions/editor.php:237
146
+ msgid "Dimensions:"
147
+ msgstr "Dimensões:"
148
+
149
+ # @ cpt_lang
150
+ #: functions/editor.php:238
151
+ msgid "Ratio:"
152
+ msgstr "Relação:"
153
+
154
+ # @ cpt_lang
155
+ #: functions/editor.php:421
156
+ msgid "Crop Thumbnails"
157
+ msgstr "Cortar Miniaturas"
158
+
159
+ #: functions/editor.php:425
160
+ msgid "Crop Featured Image"
161
+ msgstr "Cortar Imagem Destacada"
162
+
163
+ # @ cpt_lang
164
+ #: functions/editor.php:439
165
+ msgid "Crop Thumbnail"
166
+ msgstr "Cortar Miniatura"
167
+
168
+ # @ cpt_lang
169
+ #: functions/save.php:95
170
+ #, php-format
171
+ msgid "Cant generate filesize \"%s\"."
172
+ msgstr "Não é possível gerar o tamanho \"%s\"."
173
+
174
+ # @ cpt_lang
175
+ #: functions/save.php:102
176
+ msgid "Cant copy temporary file to media-library."
177
+ msgstr "Não é possível copiar arquivo temporário para a biblioteca de mídia."
178
+
179
+ # @ cpt_lang
180
+ #: functions/save.php:106
181
+ msgid "Cant delete temporary file."
182
+ msgstr "Não é possível excluir arquivo temporário."
183
+
184
+ # @ cpt_lang
185
+ #: functions/save.php:172
186
+ msgid "ERROR: Security Check failed (maybe a timeout - please try again)."
187
+ msgstr "ERRO: Verificação de Segurança falhou (talvez pelo tempo limite ter sido atingido - por favor, tente novamente)."
188
+
189
+ # @ cpt_lang
190
+ #: functions/save.php:176
191
+ msgid "ERROR: Submitted data are not complete."
192
+ msgstr "ERRO: Dados enviados não estão completos."
193
+
194
+ # @ cpt_lang
195
+ #: functions/save.php:184
196
+ msgid "A cropping with this dimensions on these Image ist not possible."
197
+ msgstr "Um corte com estas dimensões sobre esta imagem não é possível."
198
+
199
+ # @ cpt_lang
200
+ #: functions/save.php:195
201
+ msgid "ERROR: Can`t find original Image in Database!"
202
+ msgstr "ERRO: Não é possível localizar a imagem original no banco de dados!"
203
+
204
+ # @ cpt_lang
205
+ #: functions/save.php:198
206
+ msgid "ERROR: Can`t find original Imagefile!"
207
+ msgstr "ERRO: Não é possível encontrar arquivo de imagem original!"
208
+
209
+ # @ cpt_lang
210
+ #: functions/save.php:201
211
+ msgid "ERROR: Can`t find original Image-Metadata!"
212
+ msgstr "ERRO: Não é possível encontrar os metadados da imagem original!"
213
+
214
+ # @ cpt_lang
215
+ #: functions/settings.php:16
216
+ #: functions/settings.php:30
217
+ msgid "Settings"
218
+ msgstr "Configurações"
219
+
220
+ # @ cpt_lang
221
+ #: functions/settings.php:23
222
+ msgid "Crop Post Thumbnail Page"
223
+ msgstr "Cortar miniaturas na página do post"
224
+
225
+ # @ cpt_lang
226
+ #: functions/settings.php:35
227
+ msgid "Save Changes"
228
+ msgstr "Salvar Mudanças"
229
+
230
+ # @ cpt_lang
231
+ #: functions/settings.php:39
232
+ msgid "Support the plugin-author"
233
+ msgstr "Apoiar o autor do plugin"
234
+
235
+ # @ cpt_lang
236
+ #: functions/settings.php:40
237
+ msgid "You can support the plugin-author <br />(and let him know you love this plugin) <br />by donating via Paypal. Thanks a lot!"
238
+ msgstr "Você pode apoiar o autor do plugin <br />(e deixá-lo saber que você ama este plugin)<br /> doando via Paypal. Muito obrigado!"
239
+
240
+ # @ cpt_lang
241
+ #: functions/settings.php:60
242
+ msgid "Sizes and Posttypes"
243
+ msgstr "Tamanhos e Tipos de Post"
244
+
245
+ # @ cpt_lang
246
+ #: functions/settings.php:61
247
+ msgid "Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries."
248
+ msgstr "Escolha os tamanhos de imagem que você deseja esconder. Escolha um tipo de post para evitar qualquer uso do plugin para essas entradas."
249
+
250
+ # @ cpt_lang
251
+ #: functions/settings.php:66
252
+ msgid "Crop-Thumbnails is created to make cropping easy for the user. Often times the user only need to crop one, in dependence of the post-type. But the system will create also all other sizes. So, here you can select for what post-type what sizes should be visible in the plugin interface."
253
+ msgstr "Crop-Thumbnails é criado para fazer recorte fácil para o usuário. Muitas vezes o utilizador necessita somente de um recorte, pois depende dele em seu post. Mas o sistema irá criar também todos os outros tamanhos. Então, aqui você pode selecionar para que as miniaturas de seu post sejam visíveis na interface do plugin."
254
+
255
+ # @ cpt_lang
256
+ #: functions/settings.php:67
257
+ msgid "Crop-Thumbnails will only show croped images - sizes with no crop will always be hidden."
258
+ msgstr "Crop-Thumbnails só irá mostrar imagens cortadas - tamanhos sem cortes serão sempre escondidos."
259
+
readme.txt CHANGED
@@ -13,7 +13,7 @@ License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
  == Description ==
14
 
15
  The plugin enhance functionality to crop your thumbnails individuell and simple. It add links on 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) image-sizes and cut-off the part of the image you want.
17
 
18
  It is possible to filter the list of available image-sizes (in dependency to post-types) in the settings (Settings > Crop-Thumbnails).
19
 
@@ -32,6 +32,12 @@ You can use the built in installer and upgrader, or you can install the plugin m
32
  * English
33
  * German (de_DE)
34
  * brazilian portuguese (pt_BR) - thanks to Alex Meusburger
 
 
 
 
 
 
35
 
36
  = I have cropped the image but the old one is used on the page. =
37
  If you had viewed your image on the site before, your browser has cached the image. Go tell them to reload the fresh image from the server by hitting "F5".
@@ -43,15 +49,15 @@ Note that the image in the featured-image box will only be a preview, to show wh
43
  = Is it possible to crop an non-cropped image-size? =
44
  Currently not.
45
 
46
- = What ideas for further releases you have? =
47
- * allow cropping window in frontside
48
- * allow new crop sizes beside the ones added with the add_image_size() function (for using less disk space)
49
- * reset standard image-crop
50
- * let the user generate all image-sizes at once by define a "central point of interest"
51
- * maybe use the new WP_Image_Editor class
52
- * add a option-button for dont use the minSize-Boundary of jcrop
53
- * put editor-options into a collapsible menu
54
 
 
 
 
 
 
55
 
56
  == Screenshots ==
57
 
@@ -62,6 +68,11 @@ Currently not.
62
  5. Choose what image-sizes should be hidden (for what post-types), for better usability.
63
 
64
  == Changelog ==
 
 
 
 
 
65
  = 0.8.1 =
66
  * fix warning: when settings are saved
67
 
13
  == Description ==
14
 
15
  The plugin enhance functionality to crop your thumbnails individuell and simple. It add links on 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
  It is possible to filter the list of available image-sizes (in dependency to post-types) in the settings (Settings > Crop-Thumbnails).
19
 
32
  * English
33
  * German (de_DE)
34
  * brazilian portuguese (pt_BR) - thanks to Alex Meusburger
35
+ * Ukrainian (uk) - thanks to Jurko Chervony from www.skinik.name
36
+
37
+ = What internal rules use the plugin for cropping? =
38
+ * The plugin will only crop image-sizes where crop is set to "true" (hard crop mode - see: http://codex.wordpress.org/Function_Reference/add_image_size).
39
+ * If you had set one of image dimension in add_image_size to "0" or "9999" (an set crop to true) the plugin will crop it in the ratio of the original image.
40
+ * You are able to crop all images with the same ratio at once (default) or and any imagesize (and ratio) seperate.
41
 
42
  = I have cropped the image but the old one is used on the page. =
43
  If you had viewed your image on the site before, your browser has cached the image. Go tell them to reload the fresh image from the server by hitting "F5".
49
  = Is it possible to crop an non-cropped image-size? =
50
  Currently not.
51
 
52
+ = Is it possible to adjust the css-style of the crop-thumbnail window? =
53
+ Yes, for a simple test, copy the css/cpt-window.css file into your template_directory and make some change.
54
+ Then add this code into the functions.php of your template.
 
 
 
 
 
55
 
56
+ `add_filter('crop_post_thumbnail_window_css','myCustomStyle');
57
+ function myCustomStyle($content) {
58
+ $content = get_bloginfo('template_directory').'/cpt-window.css';
59
+ return $content;
60
+ }`
61
 
62
  == Screenshots ==
63
 
68
  5. Choose what image-sizes should be hidden (for what post-types), for better usability.
69
 
70
  == Changelog ==
71
+ = 0.8.2 =
72
+ * add filter for customize the style of the crop-thumbnail content ('crop_post_thumbnail_window_css')
73
+ * add a fix for dynamic height/width images (http://wordpress.org/support/topic/dynamic-widthheight)
74
+ * add ukrainian lang (thanks to Jurko Chervony from www.skinik.name)
75
+
76
  = 0.8.1 =
77
  * fix warning: when settings are saved
78