Simple Image Sizes - Version 1.0.6

Version Description

Download this release

Release Info

Developer Rahe
Plugin Icon wp plugin Simple Image Sizes
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

Files changed (30) hide show
  1. css/images/progress-background.png +0 -0
  2. css/images/progress-bubble.png +0 -0
  3. css/images/progress-stripe.png +0 -0
  4. {jquery-ui/redmond → css}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  5. {jquery-ui/redmond → css}/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  6. {jquery-ui/redmond → css}/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  7. {jquery-ui/redmond → css}/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  8. {jquery-ui/redmond → css}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  9. {jquery-ui/redmond → css}/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  10. {jquery-ui/redmond → css}/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  11. {jquery-ui/redmond → css}/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  12. {jquery-ui/redmond → css}/images/ui-icons_217bc0_256x240.png +0 -0
  13. {jquery-ui/redmond → css}/images/ui-icons_2e83ff_256x240.png +0 -0
  14. {jquery-ui/redmond → css}/images/ui-icons_469bdd_256x240.png +0 -0
  15. {jquery-ui/redmond → css}/images/ui-icons_6da8d5_256x240.png +0 -0
  16. {jquery-ui/redmond → css}/images/ui-icons_cd0a0a_256x240.png +0 -0
  17. {jquery-ui/redmond → css}/images/ui-icons_d8e7f3_256x240.png +0 -0
  18. {jquery-ui/redmond → css}/images/ui-icons_f9bd01_256x240.png +0 -0
  19. jquery-ui/redmond/jquery-ui-1.8.10.custom.css → css/jquery-ui-1.8.10.progressbar.css +0 -0
  20. css/sis-style.css +58 -50
  21. inc/class.admin.php +610 -610
  22. jquery-ui/ui.progressbar.js +0 -13
  23. js/custom_sizes.min.js +0 -1
  24. js/{jquery-ui-1.8.10.custom.min.js → jquery-ui-1.8.10.progressbar.min.js} +1 -1
  25. js/{custom_sizes.js → sis.js} +22 -18
  26. js/sis.min.js +14 -0
  27. languages/sis-fr_FR.mo +0 -0
  28. languages/sis-fr_FR.po +4 -4
  29. readme.txt +55 -51
  30. simple_image_sizes.php +46 -46
css/images/progress-background.png ADDED
Binary file
css/images/progress-bubble.png ADDED
Binary file
css/images/progress-stripe.png ADDED
Binary file
{jquery-ui/redmond → css}/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_flat_55_fbec88_40x100.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_glass_75_d0e5f5_1x400.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_glass_85_dfeffc_1x400.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_inset-hard_100_f5f8f9_1x100.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-bg_inset-hard_100_fcfdfd_1x100.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_217bc0_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_469bdd_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_6da8d5_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_d8e7f3_256x240.png RENAMED
File without changes
{jquery-ui/redmond → css}/images/ui-icons_f9bd01_256x240.png RENAMED
File without changes
jquery-ui/redmond/jquery-ui-1.8.10.custom.css → css/jquery-ui-1.8.10.progressbar.css RENAMED
File without changes
css/sis-style.css CHANGED
@@ -1,51 +1,59 @@
1
- .delete_size {
2
- width: 90px;
3
- padding: 0px;
4
- display:inline-block;
5
- position:relative;
6
- text-indent:16px;
7
- margin-right:5px;
8
- text-align:center
9
- }
10
-
11
- .delete_size_icon {
12
- float: right;
13
- top: 2px;
14
- position:absolute;
15
- left: 0px;
16
- }
17
-
18
- .progress .progress-percent {
19
- position:absolute;
20
- left:50%;
21
- top:50%;
22
- width:50px;
23
- margin-left:-25px;
24
- height:25px;
25
- margin-top:-9px;
26
- font-weight:bold;
27
- text-align:center;
28
- }
29
-
30
- .wrapper {
31
- display: inline-block;
32
- float: left;
33
- width: 45%;
34
- }
35
-
36
- #regenerate_message {
37
- display:none;
38
- }
39
-
40
- .progress {
41
- position:relative;
42
- height:25px;
43
- }
44
-
45
- #thumb {
46
- display:none;
47
- }
48
-
49
- #ajax_thumbnail_rebuild {
50
- margin-top:40px;
 
 
 
 
 
 
 
 
51
  }
1
+ .delete_size {
2
+ width: 90px;
3
+ padding: 0px;
4
+ display:inline-block;
5
+ position:relative;
6
+ text-indent:16px;
7
+ margin-right:5px;
8
+ text-align:center
9
+ }
10
+
11
+ .delete_size_icon {
12
+ float: right;
13
+ top: 2px;
14
+ position:absolute;
15
+ left: 0px;
16
+ }
17
+
18
+ .progress {
19
+ position:relative;
20
+ height:13px;
21
+ margin-bottom: 43px;
22
+ margin-top: 60px;
23
+ color:#FFFFFF;
24
+ display:none;
25
+ }
26
+
27
+ .progress .progress-percent {
28
+ position: absolute;
29
+ left: 0%;
30
+ top: -50px;
31
+ width: 82px;
32
+ height: 49px;
33
+ margin-top: -9px;
34
+ font-weight: bold;
35
+ background-image: url('./images/progress-bubble.png');
36
+ line-height: 39px;
37
+ text-align: center;
38
+ }
39
+
40
+ .progress.ui-widget-content { border: 1px solid #343434; background: #fcfdfd url(./images/progress-background.png) 50% bottom repeat-x; }
41
+ .progress .ui-widget-header { border: 1px solid #343434; background: #5c9ccc url(./images/progress-stripe.png) 50% 50% repeat-x; }
42
+
43
+ .wrapper {
44
+ display: inline-block;
45
+ float: left;
46
+ width: 45%;
47
+ }
48
+
49
+ #regenerate_message {
50
+ display:none;
51
+ }
52
+
53
+ #thumb {
54
+ display:none;
55
+ }
56
+
57
+ #ajax_thumbnail_rebuild {
58
+ margin-top:40px;
59
  }
inc/class.admin.php CHANGED
@@ -1,611 +1,611 @@
1
- <?php
2
- Class SISAdmin{
3
-
4
- // Original sizes
5
- public $original = array( 'thumbnail', 'medium', 'large' );
6
-
7
- public function __construct(){
8
- // Init
9
- add_action ( 'admin_menu', array( &$this, 'init' ) );
10
- add_action ( 'admin_enqueue_scripts', array( &$this, 'registerScripts' ), 11 );
11
-
12
- // Add ajax action
13
- add_action('wp_ajax_ajax_thumbnail_rebuild', array( &$this, 'ajaxThumbnailRebuildAjax' ) );
14
- add_action('wp_ajax_get_sizes', array( &$this, 'ajaxGetSizes' ) );
15
-
16
- // Add image sizes in the form
17
- add_filter( 'attachment_fields_to_edit', array( &$this, 'sizesInForm' ), 11, 2 ); // Add our sizes to media forms
18
-
19
- // Add link in plugins list
20
- add_filter('plugin_action_links', array( &$this,'addSettingsLink'), 10, 2 );
21
- }
22
-
23
- /**
24
- * Register javascripts and css.
25
- *
26
- * @access public
27
- * @return void
28
- * @author Nicolas Juen
29
- */
30
- public function registerScripts($hook_suffix = '' ) {
31
- if( $hook_suffix == 'options-media.php' ) {
32
- // Add javascript
33
- wp_enqueue_script( 'custom_image_size', SIS_URL.'js/custom_sizes.min.js', array('jquery'), '1.0' );
34
- wp_enqueue_script( 'jquery-ui-progressbar', SIS_URL.'js/jquery-ui-1.8.10.custom.min.js', array(), '1.8.10' );
35
-
36
- // Ad javascript translation
37
- wp_localize_script( 'custom_image_size', 'custom_image_size', $this->localizeVars() );
38
-
39
- // Add CSS
40
- wp_enqueue_style( 'jquery-ui-regenthumbs', SIS_URL.'jquery-ui/redmond/jquery-ui-1.8.10.custom.css', array(), '1.8.10' );
41
- wp_enqueue_style( 'sis_css', SIS_URL.'css/sis-style.css', array(), '1.0' );
42
- }
43
- }
44
-
45
- /**
46
- * Localize the var for javascript
47
- *
48
- * @access public
49
- * @return void
50
- * @author Nicolas Juen
51
- */
52
- public function localizeVars() {
53
- return array(
54
- 'ajaxUrl' => admin_url( '/admin-ajax.php' ),
55
- 'reading' => __( 'Reading attachments...', 'sis' ),
56
- 'maximumWidth' => __( 'Maximum width', 'sis' ),
57
- 'maximumHeight' => __( 'Maximum height', 'sis' ),
58
- 'crop' => __( 'Crop ?', 'sis' ),
59
- 'of' => __( ' of ', 'sis' ),
60
- 'deleteImage' => __( 'Delete', 'sis' ),
61
- 'noMedia' => __( 'No media in your site to regenerate !', 'sis' ),
62
- 'regenerating' => __( 'Regenerating ', 'sis'),
63
- 'validate' => __( 'Validate image size name', 'sis' ),
64
- 'done' => __( 'Done.', 'sis' ),
65
- 'size' => __( 'Size', 'sis' ),
66
- 'notOriginal' => __( 'Don\'t use the basic Wordpress thumbnail size name, use the form above to edit them', 'sis' ),
67
- );
68
- }
69
-
70
- /**
71
- * Add a link to the setting option page
72
- *
73
- * @access public
74
- * @param array $links
75
- * @param string $file
76
- * @return void
77
- * @author Nicolas Juen
78
- */
79
- public function addSettingsLink( $links, $file ) {
80
-
81
- if( $file != 'simple-image-sizes/simple_image_sizes.php' )
82
- return $links;
83
-
84
- $settings_link = '<a href="'.admin_url('options-media.php').'"> '.__( 'Settings', 'sis' ).' </a>';
85
- array_unshift($links, $settings_link);
86
-
87
- return $links;
88
- }
89
-
90
- /**
91
- * Init for the option page
92
- *
93
- * @access public
94
- * @return void
95
- * @author Nicolas Juen
96
- */
97
- function init() {
98
-
99
- // Check if admin
100
- if( !is_admin() )
101
- return false;
102
-
103
- // Get the image sizes
104
- global $_wp_additional_image_sizes;
105
-
106
- // Get the sizes and add the settings
107
- foreach ( get_intermediate_image_sizes() as $s ) {
108
-
109
- // Don't make the original sizes
110
- if( in_array( $s, $this->original ) )
111
- continue;
112
-
113
- // Set width
114
- if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
115
- $width = intval( $_wp_additional_image_sizes[$s]['width'] );
116
- else // For default sizes set in options
117
- $width = get_option( "{$s}_size_w" );
118
-
119
- // Set height
120
- if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
121
- $height = intval( $_wp_additional_image_sizes[$s]['height'] );
122
- else // For default sizes set in options
123
- $height = get_option( "{$s}_size_h" );
124
-
125
- //Set crop
126
- if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
127
- $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
128
- else // For default sizes set in options
129
- $crop = get_option( "{$s}_crop" );
130
-
131
- // Add the setting field for this size
132
- add_settings_field( 'image_size_'.$s.'', __( 'Size ', 'sis' ).$s, array( &$this, 'imageSizes' ), 'media' , 'default', array( 'name' => $s , 'width' => $width , 'height' => $height ) );
133
-
134
- }
135
-
136
- // Register the setting for media option page
137
- register_setting( 'media', 'custom_image_sizes' );
138
-
139
- // Add the button
140
- add_settings_field( 'add_size', __( 'Add a new size', 'sis' ), array( &$this, 'addSize' ), 'media' );
141
-
142
- // Add legend
143
- add_settings_field( 'add_legend', __( 'Legend of the sizes', 'sis' ), array( &$this, 'addLegend' ), 'media' );
144
-
145
- // Add size button
146
- add_settings_field( 'get_php', __( 'Get php for theme', 'sis' ), array( &$this, 'getPhp' ), 'media' );
147
-
148
- // Add section for the thumbnail regeneration
149
- add_settings_section( 'thumbnail_regenerate', __( 'Thumbnail regeneration', 'sis' ), array( &$this, 'thumbnailRegenerate' ), 'media' );
150
- }
151
-
152
- /**
153
- * Display the row of the image size
154
- *
155
- * @access public
156
- * @param mixed $args
157
- * @return void
158
- * @author Nicolas Juen
159
- */
160
- public function imageSizes( $args ) {
161
- // Get the options
162
- $sizes = (array)get_option( 'custom_image_sizes' );
163
-
164
- $height = isset( $sizes[$args['name']]['h'] )? $sizes[$args['name']]['h'] : $args['height'] ;
165
- $width = isset( $sizes[$args['name']]['w'] )? $sizes[$args['name']]['w'] : $args['width'] ;
166
- $crop = isset( $sizes[$args['name']]['c'] ) && !empty( $sizes[$args['name']]['c'] )? '1' : '0' ;
167
- $custom = ( isset( $sizes[$args['name']]['custom'] ) && !empty( $sizes[$args['name']]['custom'] ) )? '1' : '0' ;
168
- ?>
169
- <?php if( $custom ): ?>
170
- <span class="custom_size"> <?php _e( 'Custom size', 'sis'); ?> : </span>
171
- <input name="<?php echo 'custom_image_sizes['.$args['name'].'][custom]' ?>" type="hidden" id="<?php echo 'custom_image_sizes['.$args['name'].'][custom]' ?>" value="1" />
172
- <?php else: ?>
173
- <span class="theme_size"> <?php _e( 'Theme size', 'sis'); ?> : </span>
174
- <input name="<?php echo 'custom_image_sizes['.$args['name'].'][theme]' ?>" type="hidden" id="<?php echo 'custom_image_sizes['.$args['name'].'][theme]' ?>" value="1" />
175
- <?php endif; ?>
176
- <label for="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>">
177
- <?php _e( 'Maximum width', 'sis'); ?>
178
- <input name="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>" type="text" id="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>" value="<?php echo $width ?>" class="small-text" />
179
- </label>
180
-
181
- <label for="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>">
182
- <?php _e( 'Maximum height', 'sis'); ?>
183
- <input name="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>" type="text" id="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>" value="<?php echo $height ?>" class="small-text" />
184
- </label>
185
-
186
-
187
- <label class="crop">
188
- <?php _e( 'Crop ?', 'sis'); ?>
189
- <input type='checkbox' <?php checked( $crop, 1 ) ?> name="<?php echo 'custom_image_sizes['.$args['name'].'][c]' ?>" value="1" />
190
- </label>
191
- <label class="ui-state-default ui-corner-all delete_size">
192
- <?php _e( 'Delete', 'sis'); ?>
193
- <div class="ui-icon ui-icon-circle-close delete_size_icon">
194
- </div>
195
- </label>
196
- <?php }
197
-
198
- /**
199
- * Add the button to add a size
200
- *
201
- * @access public
202
- * @return void
203
- * @author Nicolas Juen
204
- */
205
- public function addSize() { ?>
206
- <input type="button" class="button-secondary action" id="add_size" value="<?php _e( 'Add a new size of thumbnail', 'sis'); ?>" />
207
- <?php
208
- }
209
-
210
- /**
211
- * Add the button to get the php for th sizes
212
- *
213
- * @access public
214
- * @return void
215
- * @author Nicolas Juen
216
- */
217
- public function getPhp() { ?>
218
- <input type="button" class="button-secondary action" id="get_php" value="<?php _e( 'Get the PHP for the template', 'sis'); ?>" />
219
- <p> <?php _e( 'Copy and paste the code below into your Wordpress theme function file if you wanted to save them and deactivate the plugin.', 'sis'); ?> </p>
220
- <code></code>
221
- <?php
222
- }
223
-
224
- /**
225
- * Add the legend fo the colors
226
- *
227
- * @access public
228
- * @return void
229
- * @author Nicolas Juen
230
- */
231
- public function addLegend() { ?>
232
- <?php _e('The images created on your theme are <span style="color:orange">orange</span> and your custom size are <span style="color:green"> green </span>.', 'sis'); ?>
233
- <?php
234
- }
235
-
236
- /**
237
- * Display the Table of sizes and post types for regenerating
238
- *
239
- * @access public
240
- * @return void
241
- * @author Nicolas Juen
242
- */
243
- public function thumbnailRegenerate() {
244
- // Get the sizes
245
- global $_wp_additional_image_sizes;
246
- ?>
247
- <div id="sis-regen">
248
- <div class="wrapper" style="">
249
- <h4> <?php _e( 'Select which thumbnails you want to rebuild:', 'sis'); ?> </h4>
250
- <table cellspacing="0" class="widefat page fixed">
251
- <thead>
252
- <tr>
253
- <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
254
- <th class="manage-column column-author" scope="col"><?php _e( 'Size name', 'sis'); ?></th>
255
- <th class="manage-column column-author" scope="col"><?php _e( 'Width', 'sis'); ?></th>
256
- <th class="manage-column column-author" scope="col"><?php _e( 'Height', 'sis'); ?></th>
257
- <th class="manage-column column-author" scope="col"><?php _e( 'Crop ?', 'sis'); ?></th>
258
- </tr>
259
- </thead>
260
- <tboby>
261
- <?php
262
- // Display the sizes in the array
263
- foreach ( get_intermediate_image_sizes() as $s ):
264
-
265
- if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
266
- $width = intval( $_wp_additional_image_sizes[$s]['width'] );
267
- else // For default sizes set in options
268
- $width = get_option( "{$s}_size_w" );
269
-
270
- if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
271
- $height = intval( $_wp_additional_image_sizes[$s]['height'] );
272
- else // For default sizes set in options
273
- $height = get_option( "{$s}_size_h" );
274
-
275
- if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
276
- $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
277
- else // For default sizes set in options
278
- $crop = get_option( "{$s}_crop" );
279
- ?>
280
- <tr>
281
- <td>
282
- <input type="checkbox" class="thumbnails" id="<?php echo $s ?>" name="thumbnails[]" checked="checked" value="<?php echo $s ?>" />
283
- </td>
284
-
285
- <td>
286
- <label for="<?php echo $s ?>">
287
- <?php echo $s; ?>
288
- </label>
289
- </td>
290
-
291
- <td>
292
- <label for="<?php echo $s ?>">
293
- <?php echo $width;?> px
294
- </label>
295
- </td>
296
-
297
- <td>
298
- <label for="<?php echo $s ?>">
299
- <?php echo $height; ?> px
300
- </label>
301
- </td>
302
-
303
- <td>
304
- <label for="<?php echo $s ?>">
305
- <?php echo ( $crop == 1 )? 'yes':'no'; ?>
306
- </label>
307
- </td>
308
- </tr>
309
- <?php endforeach;?>
310
- </tbody>
311
- <tfoot>
312
- <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
313
- <th class="manage-column column-author" scope="col"><?php _e( 'Size name', 'sis'); ?></th>
314
- <th class="manage-column column-author" scope="col"><?php _e( 'Width', 'sis'); ?></th>
315
- <th class="manage-column column-author" scope="col"><?php _e( 'Height', 'sis'); ?></th>
316
- <th class="manage-column column-author" scope="col"><?php _e( 'Crop ?', 'sis'); ?></th>
317
- </tfoot>
318
- </table>
319
- </div>
320
- <div style="display: inline-block;width: 25%;margin-left: 15px;">
321
- <h4><?php _e( 'Select which post type source thumbnails you want to rebuild:', 'sis'); ?></h4>
322
- <table cellspacing="0" class="widefat page fixed">
323
- <thead>
324
- <tr>
325
- <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
326
- <th class="manage-column column-author" scope="col"><?php _e( 'Post type', 'sis'); ?></th>
327
- </tr>
328
- </thead>
329
- <tbody>
330
- <?php
331
- // Diplay the post types table
332
- foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $ptype ):
333
- ?>
334
- <tr>
335
- <td>
336
- <label for="<?php echo $ptype->name; ?>">
337
- <input type="checkbox" class="post_types" name="post_types[]" checked="checked" id="<?php echo $ptype->name; ?>" value="<?php echo $ptype->name; ?>" />
338
- </label>
339
- </td>
340
- <td>
341
- <label for="<?php echo $ptype->name; ?>">
342
- <em><?php echo $ptype->labels->name; ?></em>
343
- </label>
344
- </td>
345
- </tr>
346
- <?php endforeach;?>
347
- </tbody>
348
- <tfoot>
349
- <tr>
350
- <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
351
- <th class="manage-column column-author" scope="col"><?php _e( 'Post type', 'sis'); ?></th>
352
- </tr>
353
- </tfoot>
354
- </table>
355
- </div>
356
- </div>
357
-
358
- <div style="clear:both;padding-top:15px">
359
- <div id="regenerate_message"></div>
360
- <div class="progress">
361
- <div class="progress-percent" ></div>
362
- </div>
363
- <div id="thumb"><h4><?php _e( 'Last image:', 'sis'); ?></h4><img id="thumb-img" /></div>
364
- <input type="button" onClick="javascript:regenerate();" class="button" name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild" value="<?php _e( 'Regenerate Thumbnails', 'sis' ) ?>" />
365
- </div>
366
- <?php
367
- }
368
-
369
- /**
370
- * Display the add_image_size for the registered sizes
371
- *
372
- * @access public
373
- * @return void
374
- */
375
- public function ajaxGetSizes() {
376
- global $_wp_additional_image_sizes;
377
-
378
- foreach ( get_intermediate_image_sizes() as $s ):
379
-
380
- // Don't make the original sizes
381
- if( in_array( $s, $this->original ) )
382
- continue;
383
-
384
- if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
385
- $width = intval( $_wp_additional_image_sizes[$s]['width'] );
386
- else // For default sizes set in options
387
- $width = get_option( "{$s}_size_w" );
388
-
389
- if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
390
- $height = intval( $_wp_additional_image_sizes[$s]['height'] );
391
- else // For default sizes set in options
392
- $height = get_option( "{$s}_size_h" );
393
-
394
- if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
395
- $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
396
- else // For default sizes set in options
397
- $crop = get_option( "{$s}_crop" );
398
-
399
- $crop = ( $crop == 0 )? 'false' : 'true' ;
400
- ?>
401
- add_image_size( '<?php echo $s; ?>', '<?php echo $width; ?>', '<?php echo $height; ?>', '<?php echo $crop ?>' );<br />
402
- <?php endforeach;
403
-
404
- die();
405
- }
406
-
407
- /**
408
- * Rebuild the image
409
- *
410
- * @access public
411
- * @return void
412
- * @author Nicolas Juen
413
- */
414
- public function ajaxThumbnailRebuildAjax() {
415
- global $wpdb;
416
-
417
- // Get the action
418
- $action = $_POST["do"];
419
-
420
- // Get the thumbnails
421
- $thumbnails = isset( $_POST['thumbnails'] )? $_POST['thumbnails'] : NULL;
422
-
423
- if ( $action == "getlist" ) {
424
- if ( isset( $_POST['post_types'] ) && !empty( $_POST['post_types'] ) ) {
425
-
426
- // Get image medias
427
- $whichmimetype = wp_post_mime_type_where( 'image', $wpdb->posts );
428
-
429
- // Get all parent from post type
430
- $attachments = $wpdb->get_results( "SELECT *
431
- FROM $wpdb->posts
432
- WHERE 1 = 1
433
- AND post_type = 'attachment'
434
- $whichmimetype
435
- AND post_parent IN (
436
- SELECT DISTINCT ID
437
- FROM $wpdb->posts
438
- WHERE post_type IN ('".implode( "', '", $_POST['post_types'] )."')
439
- )" );
440
-
441
- } else {
442
- $attachments =& get_children( array(
443
- 'post_type' => 'attachment',
444
- 'post_mime_type' => 'image',
445
- 'numberposts' => -1,
446
- 'post_status' => null,
447
- 'post_parent' => null, // any parent
448
- 'output' => 'object',
449
- ) );
450
- }
451
-
452
- // Get the attachments
453
- foreach ( $attachments as $attachment ) {
454
- $res[] = array('id' => $attachment->ID, 'title' => $attachment->post_title);
455
- }
456
- // Return the Id's and Title of medias
457
- die( json_encode( $res ) );
458
- } else if ( $action == "regen" ) {
459
- // Get the id
460
- $id = $_POST["id"];
461
-
462
- // Check Id
463
- if( (int)$id == 0 ) {
464
- die( Null );
465
- }
466
-
467
- // Get the path
468
- $fullsizepath = get_attached_file( $id );
469
-
470
- // Regen the attachment
471
- if ( FALSE !== $fullsizepath && @file_exists( $fullsizepath ) ) {
472
- set_time_limit( 30 );
473
- wp_update_attachment_metadata( $id, $this->wp_generate_attachment_metadata_custom( $id, $fullsizepath, $thumbnails ) );
474
- }
475
-
476
- // Display the attachment url for feedback
477
- die( wp_get_attachment_thumb_url( $id ) );
478
- }
479
- }
480
-
481
- /**
482
- * Generate post thumbnail attachment meta data.
483
- *
484
- * @since 2.1.0
485
- *
486
- * @param int $attachment_id Attachment Id to process.
487
- * @param string $file Filepath of the Attached image.
488
- * @return mixed Metadata for attachment.
489
- */
490
- public function wp_generate_attachment_metadata_custom( $attachment_id, $file, $thumbnails = NULL ) {
491
- $attachment = get_post( $attachment_id );
492
-
493
- $metadata = array();
494
- if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
495
- $imagesize = getimagesize( $file );
496
- $metadata['width'] = $imagesize[0];
497
- $metadata['height'] = $imagesize[1];
498
- list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
499
- $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
500
-
501
- // Make the file path relative to the upload dir
502
- $metadata['file'] = _wp_relative_upload_path($file);
503
-
504
- // make thumbnails and other intermediate sizes
505
- global $_wp_additional_image_sizes;
506
-
507
- foreach ( get_intermediate_image_sizes() as $s ) {
508
- $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
509
- if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
510
- $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
511
- else
512
- $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
513
- if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
514
- $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
515
- else
516
- $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
517
- if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
518
- $sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
519
- else
520
- $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
521
- }
522
-
523
- $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
524
-
525
- foreach ($sizes as $size => $size_data ) {
526
- if( isset( $thumbnails ) )
527
- if( !in_array( $size, $thumbnails ) )
528
- continue;
529
-
530
- $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
531
-
532
- if ( $resized )
533
- $metadata['sizes'][$size] = $resized;
534
- }
535
-
536
- // fetch additional metadata from exif/iptc
537
- $image_meta = wp_read_image_metadata( $file );
538
- if ( $image_meta )
539
- $metadata['image_meta'] = $image_meta;
540
-
541
- }
542
-
543
- return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
544
- }
545
-
546
- /**
547
- * Add the custom sizes to the image sizes in article edition
548
- *
549
- * @access public
550
- * @param array $form_fields
551
- * @param object $post
552
- * @return void
553
- * @author Nicolas Juen
554
- * @author Additional Image Sizes (zui)
555
- */
556
- public function sizesInForm( $form_fields, $post ) {
557
- // Protect from being view in Media editor where there are no sizes
558
- if ( isset($form_fields['image-size']) ) {
559
- $out = NULL;
560
- $size_names = array();
561
- $sizes_custom = get_option( 'custom_image_sizes' );
562
- if (is_array($sizes_custom)) {
563
- foreach($sizes_custom as $key => $value) {
564
- $size_names[$key] = $key;
565
- }
566
- }
567
- foreach ( $size_names as $size => $label ) {
568
- $downsize = image_downsize($post->ID, $size);
569
-
570
- // is this size selectable?
571
- $enabled = ( $downsize[3] || 'full' == $size );
572
- $css_id = "image-size-{$size}-{$post->ID}";
573
-
574
- // We must do a clumsy search of the existing html to determine is something has been checked yet
575
- if ( FALSE === strpos('checked="checked"', $form_fields['image-size']['html']) ) {
576
-
577
- if ( empty($check) )
578
- $check = get_user_setting('imgsize'); // See if they checked a custom size last time
579
-
580
- $checked = '';
581
-
582
- // if this size is the default but that's not available, don't select it
583
- if ( $size == $check || str_replace(" ", "", $size) == $check ) {
584
- if ( $enabled )
585
- $checked = " checked='checked'";
586
- else
587
- $check = '';
588
- } elseif ( !$check && $enabled && 'thumbnail' != $size ) {
589
- // if $check is not enabled, default to the first available size that's bigger than a thumbnail
590
- $check = $size;
591
- $checked = " checked='checked'";
592
- }
593
- }
594
- $html = "<div class='image-size-item' style='min-height: 50px; margin-top: 18px;'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
595
-
596
- $html .= "<label for='{$css_id}'>$label</label>";
597
- // only show the dimensions if that choice is available
598
- if ( $enabled )
599
- $html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
600
-
601
- $html .= '</div>';
602
-
603
- $out .= $html;
604
- }
605
- $form_fields['image-size']['html'] .= $out;
606
- } // End protect from Media editor
607
-
608
- return $form_fields;
609
- }
610
- }
611
  ?>
1
+ <?php
2
+ Class SISAdmin{
3
+
4
+ // Original sizes
5
+ public $original = array( 'thumbnail', 'medium', 'large' );
6
+
7
+ public function __construct(){
8
+ // Init
9
+ add_action ( 'admin_menu', array( &$this, 'init' ) );
10
+ add_action ( 'admin_enqueue_scripts', array( &$this, 'registerScripts' ), 11 );
11
+
12
+ // Add ajax action
13
+ add_action('wp_ajax_ajax_thumbnail_rebuild', array( &$this, 'ajaxThumbnailRebuildAjax' ) );
14
+ add_action('wp_ajax_get_sizes', array( &$this, 'ajaxGetSizes' ) );
15
+
16
+ // Add image sizes in the form
17
+ add_filter( 'attachment_fields_to_edit', array( &$this, 'sizesInForm' ), 11, 2 ); // Add our sizes to media forms
18
+
19
+ // Add link in plugins list
20
+ add_filter('plugin_action_links', array( &$this,'addSettingsLink'), 10, 2 );
21
+ }
22
+
23
+ /**
24
+ * Register javascripts and css.
25
+ *
26
+ * @access public
27
+ * @return void
28
+ * @author Nicolas Juen
29
+ */
30
+ public function registerScripts($hook_suffix = '' ) {
31
+ if( isset( $hook_suffix ) && $hook_suffix == 'options-media.php' ) {
32
+ // Add javascript
33
+ wp_enqueue_script( 'sis_js', SIS_URL.'js/sis.min.js', array('jquery'), '1.5' );
34
+ wp_enqueue_script( 'jquery-ui-progressbar', SIS_URL.'js/jquery-ui-1.8.10.progressbar.min.js', array(), '1.8.10' );
35
+
36
+ // Add javascript translation
37
+ wp_localize_script( 'sis_js', 'sis', $this->localizeVars() );
38
+
39
+ // Add CSS
40
+ wp_enqueue_style( 'jquery-ui-sis', SIS_URL.'css/jquery-ui-1.8.10.progressbar.css', array(), '1.8.10' );
41
+ wp_enqueue_style( 'sis_css', SIS_URL.'css/sis-style.css', array(), '1.5' );
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Localize the var for javascript
47
+ *
48
+ * @access public
49
+ * @return void
50
+ * @author Nicolas Juen
51
+ */
52
+ public function localizeVars() {
53
+ return array(
54
+ 'ajaxUrl' => admin_url( '/admin-ajax.php' ),
55
+ 'reading' => __( 'Reading attachments...', 'sis' ),
56
+ 'maximumWidth' => __( 'Maximum width', 'sis' ),
57
+ 'maximumHeight' => __( 'Maximum height', 'sis' ),
58
+ 'crop' => __( 'Crop ?', 'sis' ),
59
+ 'of' => __( ' of ', 'sis' ),
60
+ 'deleteImage' => __( 'Delete', 'sis' ),
61
+ 'noMedia' => __( 'No media in your site to regenerate !', 'sis' ),
62
+ 'regenerating' => __( 'Regenerating ', 'sis'),
63
+ 'validate' => __( 'Validate image size name', 'sis' ),
64
+ 'done' => __( 'Done.', 'sis' ),
65
+ 'size' => __( 'Size', 'sis' ),
66
+ 'notOriginal' => __( 'Don\'t use the basic Wordpress thumbnail size name, use the form above to edit them', 'sis' ),
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Add a link to the setting option page
72
+ *
73
+ * @access public
74
+ * @param array $links
75
+ * @param string $file
76
+ * @return void
77
+ * @author Nicolas Juen
78
+ */
79
+ public function addSettingsLink( $links, $file ) {
80
+
81
+ if( $file != 'simple-image-sizes/simple_image_sizes.php' )
82
+ return $links;
83
+
84
+ $settings_link = '<a href="'.admin_url('options-media.php').'"> '.__( 'Settings', 'sis' ).' </a>';
85
+ array_unshift($links, $settings_link);
86
+
87
+ return $links;
88
+ }
89
+
90
+ /**
91
+ * Init for the option page
92
+ *
93
+ * @access public
94
+ * @return void
95
+ * @author Nicolas Juen
96
+ */
97
+ function init() {
98
+
99
+ // Check if admin
100
+ if( !is_admin() )
101
+ return false;
102
+
103
+ // Get the image sizes
104
+ global $_wp_additional_image_sizes;
105
+
106
+ // Get the sizes and add the settings
107
+ foreach ( get_intermediate_image_sizes() as $s ) {
108
+
109
+ // Don't make the original sizes
110
+ if( in_array( $s, $this->original ) )
111
+ continue;
112
+
113
+ // Set width
114
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
115
+ $width = intval( $_wp_additional_image_sizes[$s]['width'] );
116
+ else // For default sizes set in options
117
+ $width = get_option( "{$s}_size_w" );
118
+
119
+ // Set height
120
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
121
+ $height = intval( $_wp_additional_image_sizes[$s]['height'] );
122
+ else // For default sizes set in options
123
+ $height = get_option( "{$s}_size_h" );
124
+
125
+ //Set crop
126
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
127
+ $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
128
+ else // For default sizes set in options
129
+ $crop = get_option( "{$s}_crop" );
130
+
131
+ // Add the setting field for this size
132
+ add_settings_field( 'image_size_'.$s.'', __( 'Size ', 'sis' ).$s, array( &$this, 'imageSizes' ), 'media' , 'default', array( 'name' => $s , 'width' => $width , 'height' => $height ) );
133
+
134
+ }
135
+
136
+ // Register the setting for media option page
137
+ register_setting( 'media', 'custom_image_sizes' );
138
+
139
+ // Add the button
140
+ add_settings_field( 'add_size', __( 'Add a new size', 'sis' ), array( &$this, 'addSize' ), 'media' );
141
+
142
+ // Add legend
143
+ add_settings_field( 'add_legend', __( 'Legend of the sizes', 'sis' ), array( &$this, 'addLegend' ), 'media' );
144
+
145
+ // Add size button
146
+ add_settings_field( 'get_php', __( 'Get php for theme', 'sis' ), array( &$this, 'getPhp' ), 'media' );
147
+
148
+ // Add section for the thumbnail regeneration
149
+ add_settings_section( 'thumbnail_regenerate', __( 'Thumbnail regeneration', 'sis' ), array( &$this, 'thumbnailRegenerate' ), 'media' );
150
+ }
151
+
152
+ /**
153
+ * Display the row of the image size
154
+ *
155
+ * @access public
156
+ * @param mixed $args
157
+ * @return void
158
+ * @author Nicolas Juen
159
+ */
160
+ public function imageSizes( $args ) {
161
+ // Get the options
162
+ $sizes = (array)get_option( 'custom_image_sizes' );
163
+
164
+ $height = isset( $sizes[$args['name']]['h'] )? $sizes[$args['name']]['h'] : $args['height'] ;
165
+ $width = isset( $sizes[$args['name']]['w'] )? $sizes[$args['name']]['w'] : $args['width'] ;
166
+ $crop = isset( $sizes[$args['name']]['c'] ) && !empty( $sizes[$args['name']]['c'] )? '1' : '0' ;
167
+ $custom = ( isset( $sizes[$args['name']]['custom'] ) && !empty( $sizes[$args['name']]['custom'] ) )? '1' : '0' ;
168
+ ?>
169
+ <?php if( $custom ): ?>
170
+ <span class="custom_size"> <?php _e( 'Custom size', 'sis'); ?> : </span>
171
+ <input name="<?php echo 'custom_image_sizes['.$args['name'].'][custom]' ?>" type="hidden" id="<?php echo 'custom_image_sizes['.$args['name'].'][custom]' ?>" value="1" />
172
+ <?php else: ?>
173
+ <span class="theme_size"> <?php _e( 'Theme size', 'sis'); ?> : </span>
174
+ <input name="<?php echo 'custom_image_sizes['.$args['name'].'][theme]' ?>" type="hidden" id="<?php echo 'custom_image_sizes['.$args['name'].'][theme]' ?>" value="1" />
175
+ <?php endif; ?>
176
+ <label for="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>">
177
+ <?php _e( 'Maximum width', 'sis'); ?>
178
+ <input name="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>" type="text" id="<?php echo 'custom_image_sizes['.$args['name'].'][w]' ?>" value="<?php echo $width ?>" class="small-text" />
179
+ </label>
180
+
181
+ <label for="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>">
182
+ <?php _e( 'Maximum height', 'sis'); ?>
183
+ <input name="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>" type="text" id="<?php echo 'custom_image_sizes['.$args['name'].'][h]' ?>" value="<?php echo $height ?>" class="small-text" />
184
+ </label>
185
+
186
+
187
+ <label class="crop">
188
+ <?php _e( 'Crop ?', 'sis'); ?>
189
+ <input type='checkbox' <?php checked( $crop, 1 ) ?> name="<?php echo 'custom_image_sizes['.$args['name'].'][c]' ?>" value="1" />
190
+ </label>
191
+ <label class="ui-state-default ui-corner-all delete_size">
192
+ <?php _e( 'Delete', 'sis'); ?>
193
+ <div class="ui-icon ui-icon-circle-close delete_size_icon">
194
+ </div>
195
+ </label>
196
+ <?php }
197
+
198
+ /**
199
+ * Add the button to add a size
200
+ *
201
+ * @access public
202
+ * @return void
203
+ * @author Nicolas Juen
204
+ */
205
+ public function addSize() { ?>
206
+ <input type="button" class="button-secondary action" id="add_size" value="<?php _e( 'Add a new size of thumbnail', 'sis'); ?>" />
207
+ <?php
208
+ }
209
+
210
+ /**
211
+ * Add the button to get the php for th sizes
212
+ *
213
+ * @access public
214
+ * @return void
215
+ * @author Nicolas Juen
216
+ */
217
+ public function getPhp() { ?>
218
+ <input type="button" class="button-secondary action" id="get_php" value="<?php _e( 'Get the PHP for the theme', 'sis'); ?>" />
219
+ <p> <?php _e( 'Copy and paste the code below into your Wordpress theme function file if you wanted to save them and deactivate the plugin.', 'sis'); ?> </p>
220
+ <code></code>
221
+ <?php
222
+ }
223
+
224
+ /**
225
+ * Add the legend fo the colors
226
+ *
227
+ * @access public
228
+ * @return void
229
+ * @author Nicolas Juen
230
+ */
231
+ public function addLegend() { ?>
232
+ <?php _e('The images created on your theme are <span style="color:orange">orange</span> and your custom size are <span style="color:green"> green </span>.', 'sis'); ?>
233
+ <?php
234
+ }
235
+
236
+ /**
237
+ * Display the Table of sizes and post types for regenerating
238
+ *
239
+ * @access public
240
+ * @return void
241
+ * @author Nicolas Juen
242
+ */
243
+ public function thumbnailRegenerate() {
244
+ // Get the sizes
245
+ global $_wp_additional_image_sizes;
246
+ ?>
247
+ <div id="sis-regen">
248
+ <div class="wrapper" style="">
249
+ <h4> <?php _e( 'Select which thumbnails you want to rebuild:', 'sis'); ?> </h4>
250
+ <table cellspacing="0" class="widefat page fixed">
251
+ <thead>
252
+ <tr>
253
+ <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
254
+ <th class="manage-column column-author" scope="col"><?php _e( 'Size name', 'sis'); ?></th>
255
+ <th class="manage-column column-author" scope="col"><?php _e( 'Width', 'sis'); ?></th>
256
+ <th class="manage-column column-author" scope="col"><?php _e( 'Height', 'sis'); ?></th>
257
+ <th class="manage-column column-author" scope="col"><?php _e( 'Crop ?', 'sis'); ?></th>
258
+ </tr>
259
+ </thead>
260
+ <tboby>
261
+ <?php
262
+ // Display the sizes in the array
263
+ foreach ( get_intermediate_image_sizes() as $s ):
264
+
265
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
266
+ $width = intval( $_wp_additional_image_sizes[$s]['width'] );
267
+ else // For default sizes set in options
268
+ $width = get_option( "{$s}_size_w" );
269
+
270
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
271
+ $height = intval( $_wp_additional_image_sizes[$s]['height'] );
272
+ else // For default sizes set in options
273
+ $height = get_option( "{$s}_size_h" );
274
+
275
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
276
+ $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
277
+ else // For default sizes set in options
278
+ $crop = get_option( "{$s}_crop" );
279
+ ?>
280
+ <tr>
281
+ <td>
282
+ <input type="checkbox" class="thumbnails" id="<?php echo $s ?>" name="thumbnails[]" checked="checked" value="<?php echo $s ?>" />
283
+ </td>
284
+
285
+ <td>
286
+ <label for="<?php echo $s ?>">
287
+ <?php echo $s; ?>
288
+ </label>
289
+ </td>
290
+
291
+ <td>
292
+ <label for="<?php echo $s ?>">
293
+ <?php echo $width;?> px
294
+ </label>
295
+ </td>
296
+
297
+ <td>
298
+ <label for="<?php echo $s ?>">
299
+ <?php echo $height; ?> px
300
+ </label>
301
+ </td>
302
+
303
+ <td>
304
+ <label for="<?php echo $s ?>">
305
+ <?php echo ( $crop == 1 )? 'yes':'no'; ?>
306
+ </label>
307
+ </td>
308
+ </tr>
309
+ <?php endforeach;?>
310
+ </tbody>
311
+ <tfoot>
312
+ <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
313
+ <th class="manage-column column-author" scope="col"><?php _e( 'Size name', 'sis'); ?></th>
314
+ <th class="manage-column column-author" scope="col"><?php _e( 'Width', 'sis'); ?></th>
315
+ <th class="manage-column column-author" scope="col"><?php _e( 'Height', 'sis'); ?></th>
316
+ <th class="manage-column column-author" scope="col"><?php _e( 'Crop ?', 'sis'); ?></th>
317
+ </tfoot>
318
+ </table>
319
+ </div>
320
+ <div style="display: inline-block;width: 25%;margin-left: 15px;">
321
+ <h4><?php _e( 'Select which post type source thumbnails you want to rebuild:', 'sis'); ?></h4>
322
+ <table cellspacing="0" class="widefat page fixed">
323
+ <thead>
324
+ <tr>
325
+ <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
326
+ <th class="manage-column column-author" scope="col"><?php _e( 'Post type', 'sis'); ?></th>
327
+ </tr>
328
+ </thead>
329
+ <tbody>
330
+ <?php
331
+ // Diplay the post types table
332
+ foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $ptype ):
333
+ ?>
334
+ <tr>
335
+ <td>
336
+ <label for="<?php echo $ptype->name; ?>">
337
+ <input type="checkbox" class="post_types" name="post_types[]" checked="checked" id="<?php echo $ptype->name; ?>" value="<?php echo $ptype->name; ?>" />
338
+ </label>
339
+ </td>
340
+ <td>
341
+ <label for="<?php echo $ptype->name; ?>">
342
+ <em><?php echo $ptype->labels->name; ?></em>
343
+ </label>
344
+ </td>
345
+ </tr>
346
+ <?php endforeach;?>
347
+ </tbody>
348
+ <tfoot>
349
+ <tr>
350
+ <th class="manage-column column-date" scope="col"><?php _e( 'Resize ?', 'sis'); ?></th>
351
+ <th class="manage-column column-author" scope="col"><?php _e( 'Post type', 'sis'); ?></th>
352
+ </tr>
353
+ </tfoot>
354
+ </table>
355
+ </div>
356
+ </div>
357
+
358
+ <div style="clear:both;padding-top:15px">
359
+ <div id="regenerate_message"></div>
360
+ <div class="progress">
361
+ <div class="progress-percent" ></div>
362
+ </div>
363
+ <div id="thumb"><h4><?php _e( 'Last image:', 'sis'); ?></h4><img id="thumb-img" /></div>
364
+ <input type="button" onClick="javascript:regenerate();" class="button" name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild" value="<?php _e( 'Regenerate Thumbnails', 'sis' ) ?>" />
365
+ </div>
366
+ <?php
367
+ }
368
+
369
+ /**
370
+ * Display the add_image_size for the registered sizes
371
+ *
372
+ * @access public
373
+ * @return void
374
+ */
375
+ public function ajaxGetSizes() {
376
+ global $_wp_additional_image_sizes;
377
+
378
+ foreach ( get_intermediate_image_sizes() as $s ):
379
+
380
+ // Don't make the original sizes
381
+ if( in_array( $s, $this->original ) )
382
+ continue;
383
+
384
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) // For theme-added sizes
385
+ $width = intval( $_wp_additional_image_sizes[$s]['width'] );
386
+ else // For default sizes set in options
387
+ $width = get_option( "{$s}_size_w" );
388
+
389
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) // For theme-added sizes
390
+ $height = intval( $_wp_additional_image_sizes[$s]['height'] );
391
+ else // For default sizes set in options
392
+ $height = get_option( "{$s}_size_h" );
393
+
394
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) // For theme-added sizes
395
+ $crop = intval( $_wp_additional_image_sizes[$s]['crop'] );
396
+ else // For default sizes set in options
397
+ $crop = get_option( "{$s}_crop" );
398
+
399
+ $crop = ( $crop == 0 )? 'false' : 'true' ;
400
+ ?>
401
+ add_image_size( '<?php echo $s; ?>', '<?php echo $width; ?>', '<?php echo $height; ?>', '<?php echo $crop ?>' );<br />
402
+ <?php endforeach;
403
+
404
+ die();
405
+ }
406
+
407
+ /**
408
+ * Rebuild the image
409
+ *
410
+ * @access public
411
+ * @return void
412
+ * @author Nicolas Juen
413
+ */
414
+ public function ajaxThumbnailRebuildAjax() {
415
+ global $wpdb;
416
+
417
+ // Get the action
418
+ $action = $_POST["do"];
419
+
420
+ // Get the thumbnails
421
+ $thumbnails = isset( $_POST['thumbnails'] )? $_POST['thumbnails'] : NULL;
422
+
423
+ if ( $action == "getlist" ) {
424
+ if ( isset( $_POST['post_types'] ) && !empty( $_POST['post_types'] ) ) {
425
+
426
+ // Get image medias
427
+ $whichmimetype = wp_post_mime_type_where( 'image', $wpdb->posts );
428
+
429
+ // Get all parent from post type
430
+ $attachments = $wpdb->get_results( "SELECT *
431
+ FROM $wpdb->posts
432
+ WHERE 1 = 1
433
+ AND post_type = 'attachment'
434
+ $whichmimetype
435
+ AND post_parent IN (
436
+ SELECT DISTINCT ID
437
+ FROM $wpdb->posts
438
+ WHERE post_type IN ('".implode( "', '", $_POST['post_types'] )."')
439
+ )" );
440
+
441
+ } else {
442
+ $attachments =& get_children( array(
443
+ 'post_type' => 'attachment',
444
+ 'post_mime_type' => 'image',
445
+ 'numberposts' => -1,
446
+ 'post_status' => null,
447
+ 'post_parent' => null, // any parent
448
+ 'output' => 'object',
449
+ ) );
450
+ }
451
+
452
+ // Get the attachments
453
+ foreach ( $attachments as $attachment ) {
454
+ $res[] = array('id' => $attachment->ID, 'title' => $attachment->post_title);
455
+ }
456
+ // Return the Id's and Title of medias
457
+ die( json_encode( $res ) );
458
+ } else if ( $action == "regen" ) {
459
+ // Get the id
460
+ $id = $_POST["id"];
461
+
462
+ // Check Id
463
+ if( (int)$id == 0 ) {
464
+ die( Null );
465
+ }
466
+
467
+ // Get the path
468
+ $fullsizepath = get_attached_file( $id );
469
+
470
+ // Regen the attachment
471
+ if ( FALSE !== $fullsizepath && @file_exists( $fullsizepath ) ) {
472
+ set_time_limit( 30 );
473
+ wp_update_attachment_metadata( $id, $this->wp_generate_attachment_metadata_custom( $id, $fullsizepath, $thumbnails ) );
474
+ }
475
+
476
+ // Display the attachment url for feedback
477
+ die( wp_get_attachment_thumb_url( $id ) );
478
+ }
479
+ }
480
+
481
+ /**
482
+ * Generate post thumbnail attachment meta data.
483
+ *
484
+ * @since 2.1.0
485
+ *
486
+ * @param int $attachment_id Attachment Id to process.
487
+ * @param string $file Filepath of the Attached image.
488
+ * @return mixed Metadata for attachment.
489
+ */
490
+ public function wp_generate_attachment_metadata_custom( $attachment_id, $file, $thumbnails = NULL ) {
491
+ $attachment = get_post( $attachment_id );
492
+
493
+ $metadata = array();
494
+ if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
495
+ $imagesize = getimagesize( $file );
496
+ $metadata['width'] = $imagesize[0];
497
+ $metadata['height'] = $imagesize[1];
498
+ list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
499
+ $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
500
+
501
+ // Make the file path relative to the upload dir
502
+ $metadata['file'] = _wp_relative_upload_path($file);
503
+
504
+ // make thumbnails and other intermediate sizes
505
+ global $_wp_additional_image_sizes;
506
+
507
+ foreach ( get_intermediate_image_sizes() as $s ) {
508
+ $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
509
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
510
+ $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
511
+ else
512
+ $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
513
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
514
+ $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
515
+ else
516
+ $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
517
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
518
+ $sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
519
+ else
520
+ $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
521
+ }
522
+
523
+ $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
524
+
525
+ foreach ($sizes as $size => $size_data ) {
526
+ if( isset( $thumbnails ) )
527
+ if( !in_array( $size, $thumbnails ) )
528
+ continue;
529
+
530
+ $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
531
+
532
+ if ( $resized )
533
+ $metadata['sizes'][$size] = $resized;
534
+ }
535
+
536
+ // fetch additional metadata from exif/iptc
537
+ $image_meta = wp_read_image_metadata( $file );
538
+ if ( $image_meta )
539
+ $metadata['image_meta'] = $image_meta;
540
+
541
+ }
542
+
543
+ return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
544
+ }
545
+
546
+ /**
547
+ * Add the custom sizes to the image sizes in article edition
548
+ *
549
+ * @access public
550
+ * @param array $form_fields
551
+ * @param object $post
552
+ * @return void
553
+ * @author Nicolas Juen
554
+ * @author Additional Image Sizes (zui)
555
+ */
556
+ public function sizesInForm( $form_fields, $post ) {
557
+ // Protect from being view in Media editor where there are no sizes
558
+ if ( isset($form_fields['image-size']) ) {
559
+ $out = NULL;
560
+ $size_names = array();
561
+ $sizes_custom = get_option( 'custom_image_sizes' );
562
+ if (is_array($sizes_custom)) {
563
+ foreach($sizes_custom as $key => $value) {
564
+ $size_names[$key] = $key;
565
+ }
566
+ }
567
+ foreach ( $size_names as $size => $label ) {
568
+ $downsize = image_downsize($post->ID, $size);
569
+
570
+ // is this size selectable?
571
+ $enabled = ( $downsize[3] || 'full' == $size );
572
+ $css_id = "image-size-{$size}-{$post->ID}";
573
+
574
+ // We must do a clumsy search of the existing html to determine is something has been checked yet
575
+ if ( FALSE === strpos('checked="checked"', $form_fields['image-size']['html']) ) {
576
+
577
+ if ( empty($check) )
578
+ $check = get_user_setting('imgsize'); // See if they checked a custom size last time
579
+
580
+ $checked = '';
581
+
582
+ // if this size is the default but that's not available, don't select it
583
+ if ( $size == $check || str_replace(" ", "", $size) == $check ) {
584
+ if ( $enabled )
585
+ $checked = " checked='checked'";
586
+ else
587
+ $check = '';
588
+ } elseif ( !$check && $enabled && 'thumbnail' != $size ) {
589
+ // if $check is not enabled, default to the first available size that's bigger than a thumbnail
590
+ $check = $size;
591
+ $checked = " checked='checked'";
592
+ }
593
+ }
594
+ $html = "<div class='image-size-item' style='min-height: 50px; margin-top: 18px;'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
595
+
596
+ $html .= "<label for='{$css_id}'>$label</label>";
597
+ // only show the dimensions if that choice is available
598
+ if ( $enabled )
599
+ $html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
600
+
601
+ $html .= '</div>';
602
+
603
+ $out .= $html;
604
+ }
605
+ $form_fields['image-size']['html'] .= $out;
606
+ } // End protect from Media editor
607
+
608
+ return $form_fields;
609
+ }
610
+ }
611
  ?>
jquery-ui/ui.progressbar.js DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- * jQuery UI Progressbar 1.7.2
3
- *
4
- * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT (MIT-LICENSE.txt)
6
- * and GPL (GPL-LICENSE.txt) licenses.
7
- *
8
- * http://docs.jquery.com/UI/Progressbar
9
- *
10
- * Depends:
11
- * ui.core.js
12
- */
13
- (function(a){a.widget("ui.progressbar",{_init:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this._valueMin(),"aria-valuemax":this._valueMax(),"aria-valuenow":this._value()});this.valueDiv=a('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element);this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow").removeData("progressbar").unbind(".progressbar");this.valueDiv.remove();a.widget.prototype.destroy.apply(this,arguments)},value:function(b){if(b===undefined){return this._value()}this._setData("value",b);return this},_setData:function(b,c){switch(b){case"value":this.options.value=c;this._refreshValue();this._trigger("change",null,{});break}a.widget.prototype._setData.apply(this,arguments)},_value:function(){var b=this.options.value;if(b<this._valueMin()){b=this._valueMin()}if(b>this._valueMax()){b=this._valueMax()}return b},_valueMin:function(){var b=0;return b},_valueMax:function(){var b=100;return b},_refreshValue:function(){var b=this.value();this.valueDiv[b==this._valueMax()?"addClass":"removeClass"]("ui-corner-right");this.valueDiv.width(b+"%");this.element.attr("aria-valuenow",b)}});a.extend(a.ui.progressbar,{version:"1.7.2",defaults:{value:0}})})(jQuery);;
 
 
 
 
 
 
 
 
 
 
 
 
 
js/custom_sizes.min.js DELETED
@@ -1 +0,0 @@
1
- var i=0;jQuery(function(){jQuery("#add_size").click(addSize);jQuery(".add_size_name").live("click",registerSize);jQuery(".delete_size").live("click",deleteSize);jQuery("span.custom_size").closest("tr").children("th").css({color:"green"});jQuery("span.theme_size").closest("tr").children("th").css({color:"orange"});jQuery("#get_php").click(getPhp)});function addSize(){row='<tr valign="top" class="new_size_'+i+'">';row+='<th scope="row">';row+='<input type="text" value="thumbnail-name" id="new_size_'+i+'" />';row+="</th>";row+="<td>";row+='<input type="button" class="button-secondary action add_size_name" id="validate_'+i+'" value="'+custom_image_size.validate+'" />';row+="</td>";row+="</tr>";jQuery(this).parent().parent().before(row);i++}function getPhp(){jQuery.ajax({url:custom_image_size.ajaxUrl,type:"POST",data:"action=get_sizes",success:function(a){jQuery("#get_php").nextAll("code").html("<br />"+a)}})}function registerSize(){name=jQuery(this).closest("tr").children("th").find("input").val();id=jQuery(this).closest("tr").children("th").find("input").attr("id");if(name=="thumbnail"||name=="medium"||name=="large"){alert(custom_image_size.notOriginal);return false}output='<th scope="row">';output+=custom_image_size.size+" "+name;output+="</th>";output+="<td>";output+='<input name="custom_image_sizes['+name+'][custom]" type="hidden" id="custom_image_sizes['+name+'][custom]" value="1" />';output+='<label for="custom_image_sizes['+name+'][w]">';output+=custom_image_size.maximumWidth+' <input name="custom_image_sizes['+name+'][w] " type="text" id="custom_image_sizes['+name+'][w]" value="" class="small-text" />';output+="</label>";output+='<label for="custom_image_sizes['+name+'][h]">';output+=custom_image_size.maximumHeight+' <input name="custom_image_sizes['+name+'][h]" type="text" id="custom_image_sizes['+name+'][h]" value="" class="small-text" />';output+="</label>";output+='<label class="crop"> ';output+=custom_image_size.crop+' <input type="checkbox" name="custom_image_sizes['+name+'][c]" value="1" /> </label>';output+='<label class="ui-state-default ui-corner-all delete_size" style="width: 90px; padding: 0px; display:inline-block; position:relative; text-indent:16px;text-align:center">';output+=custom_image_size.deleteImage;output+='<div class="ui-icon ui-icon-circle-close" style="float: right; top: 2px; position:absolute;left: 0px;">';output+="</div>";output+="</label>";output+="</td>";jQuery("#"+id).parent().parent().html(output)}function deleteSize(){jQuery(this).parent().parent().remove()}function setMessage(a){jQuery("#regenerate_message").html(a).addClass("updated").addClass("fade").show();jQuery(".progress").progressbar()}function regenerate(){jQuery("#ajax_thumbnail_rebuild").attr("disabled",true);setMessage("<p>"+custom_image_size.reading+"</p>");inputs=jQuery("input.thumbnails:checked");var thumbnails="";if(inputs.length!=jQuery("input.thumbnails[type=checkbox]").length){inputs.each(function(){thumbnails+="&thumbnails[]="+jQuery(this).val()})}inputs=jQuery("input.post_types:checked");var post_types="";if(inputs.length!=jQuery("input.post_types[type=checkbox]").length){inputs.each(function(){post_types+="&post_types[]="+jQuery(this).val()})}jQuery.ajax({url:custom_image_size.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=getlist"+post_types,success:function(result){var list=eval(result);var curr=0;function regenItem(){if(!list){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();setMessage(custom_image_size.noMedia);return false}percent=(curr/list.length)*100;jQuery(".progress").progressbar("value",percent);jQuery(".progress-percent").html(Math.round(percent)+"%");if(curr>=list.length){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();setMessage(custom_image_size.done);return}setMessage(custom_image_size.regenerating+(curr+1)+custom_image_size.of+list.length+" ("+list[curr].title+")...");jQuery.ajax({url:custom_image_size.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=regen&id="+list[curr].id+thumbnails,success:function(result){jQuery("#thumb").show();jQuery("#thumb-img").attr("src",result);curr=curr+1;regenItem()}})}regenItem()},error:function(request,status,error){setMessage("Error "+request.status)}})};
 
js/{jquery-ui-1.8.10.custom.min.js → jquery-ui-1.8.10.progressbar.min.js} RENAMED
@@ -45,5 +45,5 @@ enable:function(){return this._setOption("disabled",false)},disable:function(){r
45
  */
46
  (function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");
47
  this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*
48
- this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggleClass("ui-corner-right",a===this.options.max).width(c.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.10"})})(jQuery);
49
  ;
45
  */
46
  (function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");
47
  this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*
48
+ this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggleClass("ui-corner-right",a===this.options.max).animate({width :c.toFixed(0)+"%"}, 500);this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.10"})})(jQuery);
49
  ;
js/{custom_sizes.js → sis.js} RENAMED
@@ -10,6 +10,9 @@ jQuery(function() {
10
  'color': 'orange'
11
  });
12
  jQuery('#get_php').click(getPhp);
 
 
 
13
  });
14
 
15
  function addSize() {
@@ -18,7 +21,7 @@ function addSize() {
18
  row += '<input type="text" value="thumbnail-name" id="new_size_' + i + '" />';
19
  row += '</th>';
20
  row += '<td>';
21
- row += '<input type="button" class="button-secondary action add_size_name" id="validate_' + i + '" value="' + custom_image_size.validate + '" />';
22
  row += '</td>';
23
  row += '</tr>';
24
 
@@ -28,11 +31,11 @@ function addSize() {
28
 
29
  function getPhp() {
30
  jQuery.ajax({
31
- url: custom_image_size.ajaxUrl,
32
  type: "POST",
33
  data: "action=get_sizes",
34
  success: function(result) {
35
- jQuery('#get_php').nextAll('code').html('<br />' + result);
36
  }
37
  });
38
  }
@@ -42,28 +45,28 @@ function registerSize() {
42
  id = jQuery(this).closest('tr').children('th').find('input').attr('id');
43
 
44
  if( name == 'thumbnail' || name == "medium" || name == "large" ) {
45
- alert( custom_image_size.notOriginal );
46
  return false;
47
  }
48
 
49
  output = '<th scope="row">';
50
- output += custom_image_size.size + ' ' + name;
51
  output += '</th>';
52
  output += '<td>';
53
  output += '<input name="custom_image_sizes[' + name + '][custom]" type="hidden" id="custom_image_sizes[' + name + '][custom]" value="1" />';
54
  output += '<label for="custom_image_sizes[' + name + '][w]">';
55
- output += custom_image_size.maximumWidth + ' <input name="custom_image_sizes[' + name + '][w] " type="text" id="custom_image_sizes[' + name + '][w]" value="" class="small-text" />'
56
  output += '</label>';
57
 
58
  output += '<label for="custom_image_sizes[' + name + '][h]">';
59
- output += custom_image_size.maximumHeight + ' <input name="custom_image_sizes[' + name + '][h]" type="text" id="custom_image_sizes[' + name + '][h]" value="" class="small-text" />';
60
  output += '</label>';
61
 
62
  output += '<label class="crop"> '
63
- output += custom_image_size.crop + ' <input type="checkbox" name="custom_image_sizes[' + name + '][c]" value="1" /> </label>';
64
 
65
  output += '<label class="ui-state-default ui-corner-all delete_size" style="width: 90px; padding: 0px; display:inline-block; position:relative; text-indent:16px;text-align:center">';
66
- output += custom_image_size.deleteImage;
67
  output += '<div class="ui-icon ui-icon-circle-close" style="float: right; top: 2px; position:absolute;left: 0px;">';
68
  output += '</div>';
69
  output += '</label>';
@@ -85,7 +88,7 @@ function setMessage(msg) {
85
 
86
  function regenerate() {
87
  jQuery("#ajax_thumbnail_rebuild").attr("disabled", true);
88
- setMessage("<p>" + custom_image_size.reading + "</p>");
89
 
90
  inputs = jQuery('input.thumbnails:checked');
91
  var thumbnails = '';
@@ -104,35 +107,36 @@ function regenerate() {
104
  }
105
 
106
  jQuery.ajax({
107
- url: custom_image_size.ajaxUrl,
108
  type: "POST",
109
  data: "action=ajax_thumbnail_rebuild&do=getlist" + post_types,
110
  success: function(result) {
111
  var list = eval(result);
112
  var curr = 0;
113
-
 
114
  function regenItem() {
115
  if (!list) {
116
  jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");
117
  jQuery(".progress, #thumb").hide();
118
 
119
- setMessage(custom_image_size.noMedia);
120
  return false;
121
  }
122
  percent = (curr / list.length) * 100;
123
  jQuery(".progress").progressbar("value", percent);
124
- jQuery(".progress-percent").html(Math.round(percent) + "%");
125
  if (curr >= list.length) {
126
  jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");
127
  jQuery(".progress, #thumb").hide();
128
 
129
- setMessage(custom_image_size.done);
130
  return;
131
  }
132
- setMessage(custom_image_size.regenerating + (curr + 1) + custom_image_size.of + list.length + " (" + list[curr].title + ")...");
133
 
134
  jQuery.ajax({
135
- url: custom_image_size.ajaxUrl,
136
  type: "POST",
137
  data: "action=ajax_thumbnail_rebuild&do=regen&id=" + list[curr].id + thumbnails,
138
  success: function(result) {
@@ -151,4 +155,4 @@ function regenerate() {
151
  setMessage("Error " + request.status);
152
  }
153
  });
154
- }
10
  'color': 'orange'
11
  });
12
  jQuery('#get_php').click(getPhp);
13
+ jQuery('#get_php').nextAll('code').hide();
14
+
15
+ jQuery('.progress').hide();
16
  });
17
 
18
  function addSize() {
21
  row += '<input type="text" value="thumbnail-name" id="new_size_' + i + '" />';
22
  row += '</th>';
23
  row += '<td>';
24
+ row += '<input type="button" class="button-secondary action add_size_name" id="validate_' + i + '" value="' + sis.validate + '" />';
25
  row += '</td>';
26
  row += '</tr>';
27
 
31
 
32
  function getPhp() {
33
  jQuery.ajax({
34
+ url: sis.ajaxUrl,
35
  type: "POST",
36
  data: "action=get_sizes",
37
  success: function(result) {
38
+ jQuery('#get_php').nextAll('code').html('<br />' + result).show().css( { 'display' : 'block' } );
39
  }
40
  });
41
  }
45
  id = jQuery(this).closest('tr').children('th').find('input').attr('id');
46
 
47
  if( name == 'thumbnail' || name == "medium" || name == "large" ) {
48
+ alert( sis.notOriginal );
49
  return false;
50
  }
51
 
52
  output = '<th scope="row">';
53
+ output += sis.size + ' ' + name;
54
  output += '</th>';
55
  output += '<td>';
56
  output += '<input name="custom_image_sizes[' + name + '][custom]" type="hidden" id="custom_image_sizes[' + name + '][custom]" value="1" />';
57
  output += '<label for="custom_image_sizes[' + name + '][w]">';
58
+ output += sis.maximumWidth + ' <input name="custom_image_sizes[' + name + '][w] " type="text" id="custom_image_sizes[' + name + '][w]" value="" class="small-text" />'
59
  output += '</label>';
60
 
61
  output += '<label for="custom_image_sizes[' + name + '][h]">';
62
+ output += sis.maximumHeight + ' <input name="custom_image_sizes[' + name + '][h]" type="text" id="custom_image_sizes[' + name + '][h]" value="" class="small-text" />';
63
  output += '</label>';
64
 
65
  output += '<label class="crop"> '
66
+ output += sis.crop + ' <input type="checkbox" name="custom_image_sizes[' + name + '][c]" value="1" /> </label>';
67
 
68
  output += '<label class="ui-state-default ui-corner-all delete_size" style="width: 90px; padding: 0px; display:inline-block; position:relative; text-indent:16px;text-align:center">';
69
+ output += sis.deleteImage;
70
  output += '<div class="ui-icon ui-icon-circle-close" style="float: right; top: 2px; position:absolute;left: 0px;">';
71
  output += '</div>';
72
  output += '</label>';
88
 
89
  function regenerate() {
90
  jQuery("#ajax_thumbnail_rebuild").attr("disabled", true);
91
+ setMessage("<p>" + sis.reading + "</p>");
92
 
93
  inputs = jQuery('input.thumbnails:checked');
94
  var thumbnails = '';
107
  }
108
 
109
  jQuery.ajax({
110
+ url: sis.ajaxUrl,
111
  type: "POST",
112
  data: "action=ajax_thumbnail_rebuild&do=getlist" + post_types,
113
  success: function(result) {
114
  var list = eval(result);
115
  var curr = 0;
116
+ jQuery('.progress').show();
117
+
118
  function regenItem() {
119
  if (!list) {
120
  jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");
121
  jQuery(".progress, #thumb").hide();
122
 
123
+ setMessage(sis.noMedia);
124
  return false;
125
  }
126
  percent = (curr / list.length) * 100;
127
  jQuery(".progress").progressbar("value", percent);
128
+ jQuery(".progress-percent").html(Math.round(percent) + "%").animate( { left: Math.round( percent )-2.5 + "%" }, 500 );
129
  if (curr >= list.length) {
130
  jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");
131
  jQuery(".progress, #thumb").hide();
132
 
133
+ setMessage(sis.done);
134
  return;
135
  }
136
+ setMessage(sis.regenerating + (curr + 1) + sis.of + list.length + " (" + list[curr].title + ")...");
137
 
138
  jQuery.ajax({
139
+ url: sis.ajaxUrl,
140
  type: "POST",
141
  data: "action=ajax_thumbnail_rebuild&do=regen&id=" + list[curr].id + thumbnails,
142
  success: function(result) {
155
  setMessage("Error " + request.status);
156
  }
157
  });
158
+ }
js/sis.min.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var i=0;jQuery(function(){jQuery('#add_size').click(addSize);jQuery('.add_size_name').live('click',registerSize);jQuery('.delete_size').live('click',deleteSize);jQuery('span.custom_size').closest('tr').children('th').css({'color':'green'});jQuery('span.theme_size').closest('tr').children('th').css({'color':'orange'});jQuery('#get_php').click(getPhp);jQuery('#get_php').nextAll('code').hide();jQuery('.progress').hide();});function addSize(){row='<tr valign="top" class="new_size_'+i+'">';row+='<th scope="row">';row+='<input type="text" value="thumbnail-name" id="new_size_'+i+'" />';row+='</th>';row+='<td>';row+='<input type="button" class="button-secondary action add_size_name" id="validate_'+i+'" value="'+sis.validate+'" />';row+='</td>';row+='</tr>';jQuery(this).parent().parent().before(row);i++;}
2
+ function getPhp(){jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:"action=get_sizes",success:function(result){jQuery('#get_php').nextAll('code').html('<br />'+result).show().css({'display':'block'});}});}
3
+ function registerSize(){name=jQuery(this).closest('tr').children('th').find('input').val();id=jQuery(this).closest('tr').children('th').find('input').attr('id');if(name=='thumbnail'||name=="medium"||name=="large"){alert(sis.notOriginal);return false;}
4
+ output='<th scope="row">';output+=sis.size+' '+name;output+='</th>';output+='<td>';output+='<input name="custom_image_sizes['+name+'][custom]" type="hidden" id="custom_image_sizes['+name+'][custom]" value="1" />';output+='<label for="custom_image_sizes['+name+'][w]">';output+=sis.maximumWidth+' <input name="custom_image_sizes['+name+'][w] " type="text" id="custom_image_sizes['+name+'][w]" value="" class="small-text" />'
5
+ output+='</label>';output+='<label for="custom_image_sizes['+name+'][h]">';output+=sis.maximumHeight+' <input name="custom_image_sizes['+name+'][h]" type="text" id="custom_image_sizes['+name+'][h]" value="" class="small-text" />';output+='</label>';output+='<label class="crop"> '
6
+ output+=sis.crop+' <input type="checkbox" name="custom_image_sizes['+name+'][c]" value="1" /> </label>';output+='<label class="ui-state-default ui-corner-all delete_size" style="width: 90px; padding: 0px; display:inline-block; position:relative; text-indent:16px;text-align:center">';output+=sis.deleteImage;output+='<div class="ui-icon ui-icon-circle-close" style="float: right; top: 2px; position:absolute;left: 0px;">';output+='</div>';output+='</label>';output+='</td>';jQuery('#'+id).parent().parent().html(output);}
7
+ function deleteSize(){jQuery(this).parent().parent().remove();}
8
+ function setMessage(msg){jQuery("#regenerate_message").html(msg).addClass('updated').addClass('fade').show();jQuery(".progress").progressbar();}
9
+ function regenerate(){jQuery("#ajax_thumbnail_rebuild").attr("disabled",true);setMessage("<p>"+sis.reading+"</p>");inputs=jQuery('input.thumbnails:checked');var thumbnails='';if(inputs.length!=jQuery('input.thumbnails[type=checkbox]').length){inputs.each(function(){thumbnails+='&thumbnails[]='+jQuery(this).val();});}
10
+ inputs=jQuery('input.post_types:checked');var post_types='';if(inputs.length!=jQuery('input.post_types[type=checkbox]').length){inputs.each(function(){post_types+='&post_types[]='+jQuery(this).val();});}
11
+ jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=getlist"+post_types,success:function(result){var list=eval(result);var curr=0;jQuery('.progress').show();function regenItem(){if(!list){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();setMessage(sis.noMedia);return false;}
12
+ percent=(curr/list.length)*100;jQuery(".progress").progressbar("value",percent);jQuery(".progress-percent").html(Math.round(percent)+"%").animate({left:Math.round(percent)-2.5+"%"},500);if(curr>=list.length){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();setMessage(sis.done);return;}
13
+ setMessage(sis.regenerating+(curr+1)+sis.of+list.length+" ("+list[curr].title+")...");jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=regen&id="+list[curr].id+thumbnails,success:function(result){jQuery("#thumb").show();jQuery("#thumb-img").attr("src",result);curr=curr+1;regenItem();}});}
14
+ regenItem();},error:function(request,status,error){setMessage("Error "+request.status);}});}
languages/sis-fr_FR.mo CHANGED
Binary file
languages/sis-fr_FR.po CHANGED
@@ -4,9 +4,9 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: Simple image sizes\n"
6
  "Report-Msgid-Bugs-To: \n"
7
- "POT-Creation-Date: 2011-04-12 15:00+0100\n"
8
- "PO-Revision-Date: 2011-04-12 15:02+0100\n"
9
- "Last-Translator: Nicolas <njuen@beapi.fr>\n"
10
  "Language-Team: Beapi <njuen@beapi.fr>\n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -109,7 +109,7 @@ msgid "Add a new size of thumbnail"
109
  msgstr "Ajouter une nouvelle taille de vignette"
110
 
111
  #: inc/class.admin.php:218
112
- msgid "Get the PHP for the template"
113
  msgstr "Récupérer le code PHP pour le thème"
114
 
115
  #: inc/class.admin.php:219
4
  msgstr ""
5
  "Project-Id-Version: Simple image sizes\n"
6
  "Report-Msgid-Bugs-To: \n"
7
+ "POT-Creation-Date: 2011-04-14 01:15+0100\n"
8
+ "PO-Revision-Date: 2011-04-14 01:15+0100\n"
9
+ "Last-Translator: Nicolas JUEN <njuen@beapi.fr>\n"
10
  "Language-Team: Beapi <njuen@beapi.fr>\n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
109
  msgstr "Ajouter une nouvelle taille de vignette"
110
 
111
  #: inc/class.admin.php:218
112
+ msgid "Get the PHP for the theme"
113
  msgstr "Récupérer le code PHP pour le thème"
114
 
115
  #: inc/class.admin.php:219
readme.txt CHANGED
@@ -1,52 +1,56 @@
1
- === Simple Image Sizes ===
2
- Contributors: Rahe
3
- Donate link: http://www.beapi.fr/donate/
4
- Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
- Requires at least: 3.0
6
- Tested up to: 3.1
7
- Stable tag: 1.0.5
8
-
9
- == Description ==
10
-
11
- This plugin allow create custom image sizes for your site. Override your theme sizes directly on the media option page.
12
- You can regenerate all the sizes you have just created and choose which one you wanted to regenerate.
13
- You can now get all the code to copy and paste to your function theme file.
14
-
15
- == Installation ==
16
-
17
- 1. Download, unzip and upload to your WordPress plugins directory
18
- 2. Activate the plugin within you WordPress Administration Backend
19
- 3. Go to Settings > Medias
20
- 4. Configure your new image sizes and regenerate the thumbnails !
21
-
22
- == Screenshots ==
23
-
24
- 1. Settings page
25
- 2. Regenerating
26
-
27
- == Changelog ==
28
- * 1.0.5
29
- * Only add css and js script in the media page to avoid any javascript error in other pages
30
- * Rectify css
31
- * Add function to get the code for the function.php file of the theme
32
- * Don't redefine the Wordpress basic size names
33
- * 1.0.4
34
- * Fix the add_image_size issue ( height and width reversed )
35
- * 1.0.3
36
- * Fix the plugin language
37
- * Add some translations
38
- * Externalise some css
39
- * Add sizes in the image adding to an article
40
- * Add setting link in the plugins list
41
- * Use admin_url instead of home_url
42
- * Add legend for colors
43
- * Some code refactoring
44
- * 1.0.2
45
- * Fix the plugin license
46
- * 1.0.1
47
- * Add POT file
48
- * Add french translation
49
- * 1.0
50
- * First release
51
- * Thumbnail regenerate
 
 
 
 
52
  * Image size generation
1
+ === Simple Image Sizes ===
2
+ Contributors: Rahe
3
+ Donate link: http://www.beapi.fr/donate/
4
+ Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
+ Requires at least: 3.0
6
+ Tested up to: 3.1.1
7
+ Stable tag: 1.0.6
8
+
9
+ == Description ==
10
+
11
+ This plugin allow create custom image sizes for your site. Override your theme sizes directly on the media option page.
12
+ You can regenerate all the sizes you have just created and choose which one you wanted to regenerate.
13
+ You can now get all the code to copy and paste to your function theme file.
14
+
15
+ == Installation ==
16
+
17
+ 1. Download, unzip and upload to your WordPress plugins directory
18
+ 2. Activate the plugin within you WordPress Administration Backend
19
+ 3. Go to Settings > Medias
20
+ 4. Configure your new image sizes and regenerate the thumbnails !
21
+
22
+ == Screenshots ==
23
+
24
+ 1. Settings page
25
+ 2. Regenerating
26
+
27
+ == Changelog ==
28
+ * 1.0.6
29
+ * Minify javascript names
30
+ * Change progressbar style
31
+ * Add animations on progressbar
32
+ * 1.0.5
33
+ * Only add css and js script in the media page to avoid any javascript error in other pages
34
+ * Rectify css
35
+ * Add function to get the code for the function.php file of the theme
36
+ * Don't redefine the Wordpress basic size names
37
+ * 1.0.4
38
+ * Fix the add_image_size issue ( height and width reversed )
39
+ * 1.0.3
40
+ * Fix the plugin language
41
+ * Add some translations
42
+ * Externalise some css
43
+ * Add sizes in the image adding to an article
44
+ * Add setting link in the plugins list
45
+ * Use admin_url instead of home_url
46
+ * Add legend for colors
47
+ * Some code refactoring
48
+ * 1.0.2
49
+ * Fix the plugin license
50
+ * 1.0.1
51
+ * Add POT file
52
+ * Add french translation
53
+ * 1.0
54
+ * First release
55
+ * Thumbnail regenerate
56
  * Image size generation
simple_image_sizes.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php
2
- /*
3
- Plugin Name: Simple Image Size
4
- Plugin URI: http://wordpress.org/extend/plugins/simple-image-sizes/
5
- Description: Add options in media setting page for images sizes
6
- Version: 1.0.5
7
- Author: Rahe
8
- Author URI: http://www.beapi.fr
9
- Text Domain: sis
10
- Domain Path: /languages/
11
- Network: false
12
-
13
- Copyright 2011 Nicolas JUEN (njuen@beapi.fr) - Be-API
14
-
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License as published by
17
- the Free Software Foundation; either version 2 of the License, or
18
- (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
- */
29
-
30
- define( 'SIS_URL', plugins_url('/', __FILE__) );
31
- define( 'SIS_DIR', dirname(__FILE__) );
32
-
33
- require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.admin.php' );
34
- require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.client.php' );
35
-
36
- add_action ( 'plugins_loaded', 'initSIS' );
37
- function initSIS() {
38
- global $SIS;
39
- if( is_admin() )
40
- $SIS['admin'] = new SISAdmin();
41
-
42
- $SIS['client'] = new SISClient();
43
-
44
- load_plugin_textdomain ( 'sis', false, basename(rtrim(dirname(__FILE__), '/')) . '/languages' );
45
-
46
- }
47
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Simple Image Size
4
+ Plugin URI: http://wordpress.org/extend/plugins/simple-image-sizes/
5
+ Description: Add options in media setting page for images sizes
6
+ Version: 1.0.6
7
+ Author: Rahe
8
+ Author URI: http://www.beapi.fr
9
+ Text Domain: sis
10
+ Domain Path: /languages/
11
+ Network: false
12
+
13
+ Copyright 2011 Nicolas JUEN (njuen@beapi.fr) - Be-API
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License as published by
17
+ the Free Software Foundation; either version 2 of the License, or
18
+ (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
+ */
29
+
30
+ define( 'SIS_URL', plugins_url('/', __FILE__) );
31
+ define( 'SIS_DIR', dirname(__FILE__) );
32
+
33
+ require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.admin.php' );
34
+ require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.client.php' );
35
+
36
+ add_action ( 'plugins_loaded', 'initSIS' );
37
+ function initSIS() {
38
+ global $SIS;
39
+ if( is_admin() )
40
+ $SIS['admin'] = new SISAdmin();
41
+
42
+ $SIS['client'] = new SISClient();
43
+
44
+ load_plugin_textdomain ( 'sis', false, basename(rtrim(dirname(__FILE__), '/')) . '/languages' );
45
+
46
+ }
47
  ?>