Smush Image Compression and Optimization - Version 2.0.3

Version Description

  • Fixed (Important Update) - Image being corrupted while regenerating thumbnails
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.3

Files changed (2) hide show
  1. readme.txt +9 -3
  2. wp-smush.php +31 -24
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush ===
2
  Plugin Name: WP Smush
3
- Version: 2.0.1
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
- Contributors: WPMUDEV, alexdunane
7
  Tags: Attachment,Attachments,Compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 4.2
10
- Stable tag: 2.0.1
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
@@ -82,6 +82,12 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
85
  = 2.0.1 =
86
  * UI changes
87
 
1
  === WP Smush ===
2
  Plugin Name: WP Smush
3
+ Version: 2.0.3
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
+ Contributors: WPMUDEV, alexdunae, umeshsingla
7
  Tags: Attachment,Attachments,Compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 4.2
10
+ Stable tag: 2.0.3
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
82
 
83
  == Changelog ==
84
 
85
+ = 2.0.3 =
86
+ * Fixed (Important Update) - Image being corrupted while regenerating thumbnails
87
+
88
+ = 2.0.2 =
89
+ * Check for existing constant definition, before defining new
90
+
91
  = 2.0.1 =
92
  * UI changes
93
 
wp-smush.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Smush
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
- Version: 2.0.1
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp_smush
10
  */
@@ -35,23 +35,27 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
  /**
36
  * Constants
37
  */
38
- define( 'WP_SMUSH_VERSON', "2.0.1" );
39
-
40
- /**
41
- * Plugin base name
42
- */
43
- define( 'WP_SMUSH_BASENAME', plugin_basename( __FILE__ ) );
44
-
45
- define( 'WP_SMUSH_API', 'https://smushpro.wpmudev.org/1.0/' );
46
- define( 'WP_SMUSH_DOMAIN', 'wp_smush' );
47
- define( 'WP_SMUSH_UA', 'WP Smush/' . WP_SMUSH_VERSON . '; ' . network_home_url() );
48
- define( 'WP_SMUSH_DIR', plugin_dir_path( __FILE__ ) );
49
- define( 'WP_SMUSH_URL', plugin_dir_url( __FILE__ ) );
50
- define( 'WP_SMUSH_MAX_BYTES', 1000000 );
51
- define( 'WP_SMUSH_PREMIUM_MAX_BYTES', 8000000 );
52
- define( 'WP_SMUSH_PREFIX', 'wp-smush-' );
53
- if ( ! defined( 'WP_SMUSH_TIMEOUT' ) ) {
54
- define( 'WP_SMUSH_TIMEOUT', 30 );
 
 
 
 
55
  }
56
 
57
  require_once WP_SMUSH_DIR . "/lib/class-wp-smush-migrate.php";
@@ -103,7 +107,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
103
  }
104
 
105
  if ( $auto_smush ) {
106
- add_filter( 'wp_generate_attachment_metadata', array( $this, 'filter_generate_attachment_metadata' ), 10, 2 );
 
 
 
107
  }
108
  add_filter( 'manage_media_columns', array( $this, 'columns' ) );
109
  add_action( 'manage_media_custom_column', array( $this, 'custom_column' ), 10, 2 );
@@ -236,8 +243,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
236
  */
237
  private function _get_size_signature() {
238
  return array(
239
- 'percent' => - 1,
240
- 'bytes' => - 1,
241
  'size_before' => - 1,
242
  'size_after' => - 1,
243
  'time' => - 1
@@ -370,12 +377,13 @@ if ( ! class_exists( 'WpSmush' ) ) {
370
  * with wp_smushit()
371
  *
372
  * Filters wp_generate_attachment_metadata
 
373
  * @param $meta
374
  * @param null $ID
375
  *
376
  * @return mixed
377
  */
378
- function filter_generate_attachment_metadata( $meta, $ID = null ){
379
  //Flag to check, if original size image needs to be smushed or not
380
  $smush_full = true;
381
  $errors = new WP_Error();
@@ -478,8 +486,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
478
  update_post_meta( $ID, self::SMUSHED_META_KEY, $stats );
479
  }
480
 
481
- //return stats
482
- return $has_errors ? $meta : $stats['stats'];
483
  }
484
 
485
  /**
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
+ Version: 2.0.3
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp_smush
10
  */
35
  /**
36
  * Constants
37
  */
38
+ $prefix = 'WP_SMUSH_';
39
+ $version = '2.0.3';
40
+ $smush_constatns = array(
41
+ 'VERSON' => $version,
42
+ 'BASENAME' => plugin_basename( __FILE__ ),
43
+ 'API' => 'https://smushpro.wpmudev.org/1.0/',
44
+ 'DOMAIN' => 'wp_smush',
45
+ 'UA' => 'WP Smush/' . $version . '; ' . network_home_url(),
46
+ 'DIR' => plugin_dir_path( __FILE__ ),
47
+ 'URL' => plugin_dir_url( __FILE__ ),
48
+ 'MAX_BYTES' => 1000000,
49
+ 'PREMIUM_MAX_BYTES' => 8000000,
50
+ 'PREFIX' => 'wp-smush-',
51
+ 'TIMEOUT' => 30
52
+
53
+ );
54
+
55
+ foreach ( $smush_constatns as $const_name => $constant_val ) {
56
+ if ( ! defined( $prefix . $const_name ) ) {
57
+ define( $prefix . $const_name, $constant_val );
58
+ }
59
  }
60
 
61
  require_once WP_SMUSH_DIR . "/lib/class-wp-smush-migrate.php";
107
  }
108
 
109
  if ( $auto_smush ) {
110
+ add_filter( 'wp_generate_attachment_metadata', array(
111
+ $this,
112
+ 'filter_generate_attachment_metadata'
113
+ ), 10, 2 );
114
  }
115
  add_filter( 'manage_media_columns', array( $this, 'columns' ) );
116
  add_action( 'manage_media_custom_column', array( $this, 'custom_column' ), 10, 2 );
243
  */
244
  private function _get_size_signature() {
245
  return array(
246
+ 'percent' => - 1,
247
+ 'bytes' => - 1,
248
  'size_before' => - 1,
249
  'size_after' => - 1,
250
  'time' => - 1
377
  * with wp_smushit()
378
  *
379
  * Filters wp_generate_attachment_metadata
380
+ *
381
  * @param $meta
382
  * @param null $ID
383
  *
384
  * @return mixed
385
  */
386
+ function filter_generate_attachment_metadata( $meta, $ID = null ) {
387
  //Flag to check, if original size image needs to be smushed or not
388
  $smush_full = true;
389
  $errors = new WP_Error();
486
  update_post_meta( $ID, self::SMUSHED_META_KEY, $stats );
487
  }
488
 
489
+ return $meta;
 
490
  }
491
 
492
  /**