Smush Image Compression and Optimization - Version 1.4.3

Version Description

  • cleaner handling of file paths
Download this release

Release Info

Developer alexdunae
Plugin Icon 128x128 Smush Image Compression and Optimization
Version 1.4.3
Comparing to
See all releases

Code changes from version 1.4.2 to 1.4.3

Files changed (2) hide show
  1. readme.txt +12 -9
  2. wp-smushit.php +7 -11
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
- Version: 1.4.2
4
  Author: Dialect
5
  Author URI: http://dialect.ca/?wp_smush_it
6
  Contributors: alexdunae
7
  Tags: images, image, attachments, attachment
8
  Requires at least: 2.9
9
  Tested up to: 3.2.1
10
- Stable tag: 1.4.2
11
 
12
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
13
 
@@ -49,26 +49,29 @@ Plugin updates are announced on [http://www.twitter.com/TheCHANGELOG](http://www
49
 
50
  == Changelog ==
51
 
52
- = 1.4.2
 
 
 
53
  * bulk smush.it will no longer re-smush images that were successful
54
 
55
- = 1.4.1
56
  * bug fixes
57
 
58
- = 1.4.0
59
  * bulk smush.it
60
 
61
- = 1.3.4
62
  * bug fixes
63
 
64
- = 1.3.3
65
  * add debugging output on failure
66
 
67
- = 1.3.2
68
  * removed realpath() call
69
  * IPv6 compat
70
 
71
- = 1.3.1
72
  * handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
73
  * avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
74
 
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
+ Version: 1.4.3
4
  Author: Dialect
5
  Author URI: http://dialect.ca/?wp_smush_it
6
  Contributors: alexdunae
7
  Tags: images, image, attachments, attachment
8
  Requires at least: 2.9
9
  Tested up to: 3.2.1
10
+ Stable tag: 1.4.3
11
 
12
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
13
 
49
 
50
  == Changelog ==
51
 
52
+ = 1.4.3 =
53
+ * cleaner handling of file paths
54
+
55
+ = 1.4.2 =
56
  * bulk smush.it will no longer re-smush images that were successful
57
 
58
+ = 1.4.1 =
59
  * bug fixes
60
 
61
+ = 1.4.0 =
62
  * bulk smush.it
63
 
64
+ = 1.3.4 =
65
  * bug fixes
66
 
67
+ = 1.3.3 =
68
  * add debugging output on failure
69
 
70
+ = 1.3.2 =
71
  * removed realpath() call
72
  * IPv6 compat
73
 
74
+ = 1.3.1 =
75
  * handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
76
  * avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
77
 
wp-smushit.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Integrate the Smush.it API into WordPress.
4
- * @version 1.4.2
5
  * @package WP_SmushIt
6
  */
7
  /*
@@ -9,7 +9,7 @@ Plugin Name: WP Smush.it
9
  Plugin URI: http://dialect.ca/code/wp-smushit/
10
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
11
  Author: Dialect
12
- Version: 1.4.2
13
  Author URI: http://dialect.ca/
14
  */
15
 
@@ -28,7 +28,7 @@ define('SMUSHIT_REQ_URL', 'http://www.smushit.com/ysmush.it/ws.php?img=%s');
28
  define('SMUSHIT_BASE_URL', 'http://www.smushit.com/');
29
 
30
  define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
31
- define('WP_SMUSHIT_UA', 'WP Smush.it/1.4.2 (+http://dialect.ca/code/wp-smushit)');
32
  define('WP_SMUSHIT_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
33
 
34
 
@@ -222,6 +222,7 @@ function wp_smushit_should_resmush($previous_status) {
222
  */
223
  function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = true) {
224
  $file_path = $meta['file'];
 
225
  $store_absolute_path = true;
226
  $upload_dir = wp_upload_dir();
227
  $upload_path = trailingslashit( $upload_dir['basedir'] );
@@ -234,11 +235,9 @@ function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = tr
234
 
235
  if ( $force_resmush || wp_smushit_should_resmush( @$meta['wp_smushit'] ) ) {
236
  list($file, $msg) = wp_smushit($file_path);
237
- $meta['file'] = $file;
238
  $meta['wp_smushit'] = $msg;
239
  }
240
-
241
-
242
  // strip absolute path for Wordpress >= 2.6.2
243
  if ( FALSE === $store_absolute_path ) {
244
  $meta['file'] = str_replace($upload_path, '', $meta['file']);
@@ -249,19 +248,16 @@ function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = tr
249
  return $meta;
250
 
251
  // meta sizes don't contain a path, so we calculate one
252
- $base_dir = dirname($file_path) . '/';
253
-
254
 
255
  foreach($meta['sizes'] as $size => $data) {
256
  if ( !$force_resmush && wp_smushit_should_resmush( @$meta['sizes'][$size]['wp_smushit'] ) === FALSE ) {
257
  continue;
258
  }
259
 
260
- list($smushed_file, $results) = wp_smushit($base_dir . $data['file']);
261
- $meta['sizes'][$size]['file'] = str_replace($base_dir, '', $smushed_file);
262
  $meta['sizes'][$size]['wp_smushit'] = $results;
263
  }
264
-
265
  return $meta;
266
  }
267
 
1
  <?php
2
  /**
3
  * Integrate the Smush.it API into WordPress.
4
+ * @version 1.4.3
5
  * @package WP_SmushIt
6
  */
7
  /*
9
  Plugin URI: http://dialect.ca/code/wp-smushit/
10
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
11
  Author: Dialect
12
+ Version: 1.4.3
13
  Author URI: http://dialect.ca/
14
  */
15
 
28
  define('SMUSHIT_BASE_URL', 'http://www.smushit.com/');
29
 
30
  define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
31
+ define('WP_SMUSHIT_UA', 'WP Smush.it/1.4.3 (+http://dialect.ca/code/wp-smushit)');
32
  define('WP_SMUSHIT_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
33
 
34
 
222
  */
223
  function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = true) {
224
  $file_path = $meta['file'];
225
+
226
  $store_absolute_path = true;
227
  $upload_dir = wp_upload_dir();
228
  $upload_path = trailingslashit( $upload_dir['basedir'] );
235
 
236
  if ( $force_resmush || wp_smushit_should_resmush( @$meta['wp_smushit'] ) ) {
237
  list($file, $msg) = wp_smushit($file_path);
 
238
  $meta['wp_smushit'] = $msg;
239
  }
240
+
 
241
  // strip absolute path for Wordpress >= 2.6.2
242
  if ( FALSE === $store_absolute_path ) {
243
  $meta['file'] = str_replace($upload_path, '', $meta['file']);
248
  return $meta;
249
 
250
  // meta sizes don't contain a path, so we calculate one
251
+ $base_dir = trailingslashit( dirname($file_path) );
 
252
 
253
  foreach($meta['sizes'] as $size => $data) {
254
  if ( !$force_resmush && wp_smushit_should_resmush( @$meta['sizes'][$size]['wp_smushit'] ) === FALSE ) {
255
  continue;
256
  }
257
 
258
+ list($smushed_file, $results) = wp_smushit( $base_dir . wp_basename( $data['file'] ) );
 
259
  $meta['sizes'][$size]['wp_smushit'] = $results;
260
  }
 
261
  return $meta;
262
  }
263