Compress JPEG & PNG images - Version 2.0.2

Version Description

  • Faster Bulk Optimization page with reduced memory usage (thanks to @esmus).
  • Fixed XML-RPC error (thanks @ironmanixs, @gingerdog, @quicoto and @isaumya).
Download this release

Release Info

Developer TinyPNG
Plugin Icon 128x128 Compress JPEG & PNG images
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

RELEASE CHANGED
@@ -1,6 +1,6 @@
1
  In order to release a new version of the plugin to wordpress.org, perform the following steps:
2
 
3
- 1. Update the version in tiny-compress-images.php
4
  2. Change the 'Stable tag' in readme.txt to the new release number.
5
  3. Add release notes to readme.txt.
6
  4. If you've changed the plugin to work with newer version of WordPress add that to the readme.txt as well.
1
  In order to release a new version of the plugin to wordpress.org, perform the following steps:
2
 
3
+ 1. Update the version in tiny-compress-images.php and src/class-tiny-plugin.php
4
  2. Change the 'Stable tag' in readme.txt to the new release number.
5
  3. Add release notes to readme.txt.
6
  4. If you've changed the plugin to work with newer version of WordPress add that to the readme.txt as well.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://tinypng.com/
4
  Tags: optimize, compress, shrink, resize, faster, fit, scale, improve, images, tinypng, tinyjpg, jpeg, jpg, png, lossy, jpegmini, crunch, minify, smush, save, bandwidth, website, speed, performance, panda, wordpress app
5
  Requires at least: 3.0.6
6
  Tested up to: 4.6
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -107,6 +107,10 @@ A: Yes! After installing the plugin, go to *Media > Bulk Optimization*, and clic
107
 
108
  == Changelog ==
109
 
 
 
 
 
110
  = 2.0.1 =
111
  * Fixed a bug when searching from the admin interface (thanks to @bapcsuk).
112
 
4
  Tags: optimize, compress, shrink, resize, faster, fit, scale, improve, images, tinypng, tinyjpg, jpeg, jpg, png, lossy, jpegmini, crunch, minify, smush, save, bandwidth, website, speed, performance, panda, wordpress app
5
  Requires at least: 3.0.6
6
  Tested up to: 4.6
7
+ Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
107
 
108
  == Changelog ==
109
 
110
+ = 2.0.2 =
111
+ * Faster Bulk Optimization page with reduced memory usage (thanks to @esmus).
112
+ * Fixed XML-RPC error (thanks @ironmanixs, @gingerdog, @quicoto and @isaumya).
113
+
114
  = 2.0.1 =
115
  * Fixed a bug when searching from the admin interface (thanks to @bapcsuk).
116
 
src/class-tiny-image.php CHANGED
@@ -22,13 +22,15 @@ class Tiny_Image {
22
  const META_KEY = 'tiny_compress_images';
23
  const ORIGINAL = 0;
24
 
 
25
  private $id;
26
  private $name;
27
  private $wp_metadata;
28
  private $sizes = array();
29
  private $statistics = array();
30
 
31
- public function __construct( $id, $wp_metadata = null, $tiny_metadata = null ) {
 
32
  $this->id = $id;
33
  $this->wp_metadata = $wp_metadata;
34
  $this->parse_wp_metadata();
@@ -69,9 +71,8 @@ class Tiny_Image {
69
  && isset( $this->wp_metadata['sizes'] )
70
  && is_array( $this->wp_metadata['sizes'] ) ) {
71
 
72
- $settings = new Tiny_Settings();
73
- $active_sizes = $settings->get_sizes();
74
- $active_tinify_sizes = $settings->get_active_tinify_sizes();
75
 
76
  foreach ( $this->wp_metadata['sizes'] as $size_name => $size ) {
77
  if ( $this->sizes[ $size_name ]->has_been_compressed()
@@ -140,24 +141,24 @@ class Tiny_Image {
140
  return get_post_mime_type( $this->id );
141
  }
142
 
143
- public function compress( $settings ) {
144
- if ( $settings->get_compressor() === null || ! $this->file_type_allowed() ) {
145
  return;
146
  }
147
 
148
  $success = 0;
149
  $failed = 0;
150
 
151
- $compressor = $settings->get_compressor();
152
- $active_tinify_sizes = $settings->get_active_tinify_sizes();
153
  $uncompressed_sizes = $this->filter_image_sizes( 'uncompressed', $active_tinify_sizes );
154
 
155
  foreach ( $uncompressed_sizes as $size_name => $size ) {
156
  if ( ! $size->is_duplicate() ) {
157
  $size->add_tiny_meta_start();
158
  $this->update_tiny_post_meta();
159
- $resize = $settings->get_resize_options( $size_name );
160
- $preserve = $settings->get_preserve_options( $size_name );
161
  try {
162
  $response = $compressor->compress_file( $size->filename, $resize, $preserve );
163
  $size->add_tiny_meta( $response );
@@ -263,8 +264,7 @@ class Tiny_Image {
263
  }
264
 
265
  public function get_latest_error() {
266
- $settings = new Tiny_Settings();
267
- $active_tinify_sizes = $settings->get_active_tinify_sizes();
268
  $error_message = null;
269
  $last_timestamp = null;
270
  foreach ( $this->sizes as $size_name => $size ) {
@@ -302,9 +302,8 @@ class Tiny_Image {
302
  $this->statistics['image_sizes_optimized'] = 0;
303
  $this->statistics['available_unoptimized_sizes'] = 0;
304
 
305
- $settings = new Tiny_Settings();
306
- $active_sizes = $settings->get_sizes();
307
- $active_tinify_sizes = $settings->get_active_tinify_sizes();
308
 
309
  foreach ( $this->sizes as $size_name => $size ) {
310
  if ( ! $size->is_duplicate() ) {
@@ -342,7 +341,7 @@ class Tiny_Image {
342
  return $this->statistics;
343
  }
344
 
345
- public static function get_optimization_statistics( $result = null ) {
346
  global $wpdb;
347
 
348
  if ( is_null( $result ) ) {
@@ -390,7 +389,12 @@ class Tiny_Image {
390
  if ( ! is_array( $tiny_metadata ) ) {
391
  $tiny_metadata = array();
392
  }
393
- $tiny_image = new Tiny_Image( $result[ $i ]['ID'], $wp_metadata, $tiny_metadata );
 
 
 
 
 
394
  $image_stats = $tiny_image->get_statistics();
395
  $stats['uploaded-images']++;
396
  $stats['available-unoptimised-sizes'] += $image_stats['available_unoptimized_sizes'];
22
  const META_KEY = 'tiny_compress_images';
23
  const ORIGINAL = 0;
24
 
25
+ private $settings;
26
  private $id;
27
  private $name;
28
  private $wp_metadata;
29
  private $sizes = array();
30
  private $statistics = array();
31
 
32
+ public function __construct( $settings, $id, $wp_metadata = null, $tiny_metadata = null ) {
33
+ $this->settings = $settings;
34
  $this->id = $id;
35
  $this->wp_metadata = $wp_metadata;
36
  $this->parse_wp_metadata();
71
  && isset( $this->wp_metadata['sizes'] )
72
  && is_array( $this->wp_metadata['sizes'] ) ) {
73
 
74
+ $active_sizes = $this->settings->get_sizes();
75
+ $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
 
76
 
77
  foreach ( $this->wp_metadata['sizes'] as $size_name => $size ) {
78
  if ( $this->sizes[ $size_name ]->has_been_compressed()
141
  return get_post_mime_type( $this->id );
142
  }
143
 
144
+ public function compress() {
145
+ if ( $this->settings->get_compressor() === null || ! $this->file_type_allowed() ) {
146
  return;
147
  }
148
 
149
  $success = 0;
150
  $failed = 0;
151
 
152
+ $compressor = $this->settings->get_compressor();
153
+ $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
154
  $uncompressed_sizes = $this->filter_image_sizes( 'uncompressed', $active_tinify_sizes );
155
 
156
  foreach ( $uncompressed_sizes as $size_name => $size ) {
157
  if ( ! $size->is_duplicate() ) {
158
  $size->add_tiny_meta_start();
159
  $this->update_tiny_post_meta();
160
+ $resize = $this->settings->get_resize_options( $size_name );
161
+ $preserve = $this->settings->get_preserve_options( $size_name );
162
  try {
163
  $response = $compressor->compress_file( $size->filename, $resize, $preserve );
164
  $size->add_tiny_meta( $response );
264
  }
265
 
266
  public function get_latest_error() {
267
+ $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
 
268
  $error_message = null;
269
  $last_timestamp = null;
270
  foreach ( $this->sizes as $size_name => $size ) {
302
  $this->statistics['image_sizes_optimized'] = 0;
303
  $this->statistics['available_unoptimized_sizes'] = 0;
304
 
305
+ $active_sizes = $this->settings->get_sizes();
306
+ $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
 
307
 
308
  foreach ( $this->sizes as $size_name => $size ) {
309
  if ( ! $size->is_duplicate() ) {
341
  return $this->statistics;
342
  }
343
 
344
+ public static function get_optimization_statistics( $settings, $result = null ) {
345
  global $wpdb;
346
 
347
  if ( is_null( $result ) ) {
389
  if ( ! is_array( $tiny_metadata ) ) {
390
  $tiny_metadata = array();
391
  }
392
+ $tiny_image = new Tiny_Image(
393
+ $settings,
394
+ $result[ $i ]['ID'],
395
+ $wp_metadata,
396
+ $tiny_metadata
397
+ );
398
  $image_stats = $tiny_image->get_statistics();
399
  $stats['uploaded-images']++;
400
  $stats['available-unoptimised-sizes'] += $image_stats['available_unoptimized_sizes'];
src/class-tiny-plugin.php CHANGED
@@ -19,6 +19,7 @@
19
  */
20
 
21
  class Tiny_Plugin extends Tiny_WP_Base {
 
22
  const MEDIA_COLUMN = self::NAME;
23
  const DATETIME_FORMAT = 'Y-m-d G:i:s';
24
 
@@ -32,14 +33,11 @@ class Tiny_Plugin extends Tiny_WP_Base {
32
  }
33
 
34
  public static function version() {
35
- if ( is_null( self::$version ) ) {
36
- $plugin_data = get_plugin_data( dirname( __FILE__ ) . '/../tiny-compress-images.php' );
37
- self::$version = $plugin_data['Version'];
38
- }
39
- return self::$version;
40
  }
41
 
42
-
43
  public function __construct() {
44
  parent::__construct();
45
 
@@ -144,10 +142,15 @@ class Tiny_Plugin extends Tiny_WP_Base {
144
  }
145
 
146
  public function enqueue_scripts( $hook ) {
147
- wp_enqueue_style( self::NAME .'_admin', plugins_url( '/css/admin.css', __FILE__ ),
148
- array(), self::version() );
149
- wp_register_script( self::NAME .'_admin', plugins_url( '/js/admin.js', __FILE__ ),
150
- array(), self::version(), true );
 
 
 
 
 
151
 
152
  // WordPress < 3.3 does not handle multidimensional arrays
153
  wp_localize_script( self::NAME .'_admin', 'tinyCompress', array(
@@ -196,7 +199,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
196
 
197
  public function compress_on_upload( $metadata, $attachment_id ) {
198
  if ( ! empty( $metadata ) ) {
199
- $tiny_image = new Tiny_Image( $attachment_id, $metadata );
200
  $result = $tiny_image->compress( $this->settings );
201
  return $tiny_image->get_wp_metadata();
202
  } else {
@@ -235,7 +238,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
235
  exit;
236
  }
237
 
238
- $tiny_image = new Tiny_Image( $id, $metadata );
239
  $result = $tiny_image->compress( $this->settings );
240
 
241
  // The wp_update_attachment_metadata call is thrown because the
@@ -280,11 +283,11 @@ class Tiny_Plugin extends Tiny_WP_Base {
280
  exit;
281
  }
282
 
283
- $tiny_image_before = new Tiny_Image( $id, $metadata );
284
  $image_statistics_before = $tiny_image_before->get_statistics();
285
  $size_before = $image_statistics_before['optimized_total_size'];
286
 
287
- $tiny_image = new Tiny_Image( $id, $metadata );
288
  $result = $tiny_image->compress( $this->settings );
289
  $image_statistics = $tiny_image->get_statistics();
290
  wp_update_attachment_metadata( $id, $tiny_image->get_wp_metadata() );
@@ -324,7 +327,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
324
  if ( ! $this->check_ajax_referer() ) {
325
  exit();
326
  }
327
- $stats = Tiny_Image::get_optimization_statistics();
328
  echo json_encode( $stats );
329
  exit();
330
  }
@@ -358,7 +361,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
358
 
359
  public function render_media_column( $column, $id ) {
360
  if ( self::MEDIA_COLUMN === $column ) {
361
- $tiny_image = new Tiny_Image( $id );
362
  if ( $tiny_image->file_type_allowed() ) {
363
  echo '<div class="tiny-ajax-container">';
364
  $this->render_compress_details( $tiny_image );
@@ -369,7 +372,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
369
 
370
  public function show_media_info() {
371
  global $post;
372
- $tiny_image = new Tiny_Image( $post->ID );
373
  if ( $tiny_image->file_type_allowed() ) {
374
  echo '<div class="misc-pub-section tiny-compress-images">';
375
  echo '<h4>';
@@ -392,7 +395,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
392
  }
393
 
394
  public function render_bulk_optimization_page() {
395
- $stats = Tiny_Image::get_optimization_statistics();
396
  $estimated_costs = Tiny_Compress::estimate_cost(
397
  $stats['available-unoptimised-sizes'],
398
  $this->settings->get_compression_count()
19
  */
20
 
21
  class Tiny_Plugin extends Tiny_WP_Base {
22
+ const VERSION = '2.0.2';
23
  const MEDIA_COLUMN = self::NAME;
24
  const DATETIME_FORMAT = 'Y-m-d G:i:s';
25
 
33
  }
34
 
35
  public static function version() {
36
+ /* Avoid using get_plugin_data() because it is not loaded early enough
37
+ in xmlrpc.php. */
38
+ return self::VERSION;
 
 
39
  }
40
 
 
41
  public function __construct() {
42
  parent::__construct();
43
 
142
  }
143
 
144
  public function enqueue_scripts( $hook ) {
145
+ wp_enqueue_style( self::NAME .'_admin',
146
+ plugins_url( '/css/admin.css', __FILE__ ),
147
+ array(), self::version()
148
+ );
149
+
150
+ wp_register_script( self::NAME .'_admin',
151
+ plugins_url( '/js/admin.js', __FILE__ ),
152
+ array(), self::version(), true
153
+ );
154
 
155
  // WordPress < 3.3 does not handle multidimensional arrays
156
  wp_localize_script( self::NAME .'_admin', 'tinyCompress', array(
199
 
200
  public function compress_on_upload( $metadata, $attachment_id ) {
201
  if ( ! empty( $metadata ) ) {
202
+ $tiny_image = new Tiny_Image( $this->settings, $attachment_id, $metadata );
203
  $result = $tiny_image->compress( $this->settings );
204
  return $tiny_image->get_wp_metadata();
205
  } else {
238
  exit;
239
  }
240
 
241
+ $tiny_image = new Tiny_Image( $this->settings, $id, $metadata );
242
  $result = $tiny_image->compress( $this->settings );
243
 
244
  // The wp_update_attachment_metadata call is thrown because the
283
  exit;
284
  }
285
 
286
+ $tiny_image_before = new Tiny_Image( $this->settings, $id, $metadata );
287
  $image_statistics_before = $tiny_image_before->get_statistics();
288
  $size_before = $image_statistics_before['optimized_total_size'];
289
 
290
+ $tiny_image = new Tiny_Image( $this->settings, $id, $metadata );
291
  $result = $tiny_image->compress( $this->settings );
292
  $image_statistics = $tiny_image->get_statistics();
293
  wp_update_attachment_metadata( $id, $tiny_image->get_wp_metadata() );
327
  if ( ! $this->check_ajax_referer() ) {
328
  exit();
329
  }
330
+ $stats = Tiny_Image::get_optimization_statistics( $this->settings );
331
  echo json_encode( $stats );
332
  exit();
333
  }
361
 
362
  public function render_media_column( $column, $id ) {
363
  if ( self::MEDIA_COLUMN === $column ) {
364
+ $tiny_image = new Tiny_Image( $this->settings, $id );
365
  if ( $tiny_image->file_type_allowed() ) {
366
  echo '<div class="tiny-ajax-container">';
367
  $this->render_compress_details( $tiny_image );
372
 
373
  public function show_media_info() {
374
  global $post;
375
+ $tiny_image = new Tiny_Image( $this->settings, $post->ID );
376
  if ( $tiny_image->file_type_allowed() ) {
377
  echo '<div class="misc-pub-section tiny-compress-images">';
378
  echo '<h4>';
395
  }
396
 
397
  public function render_bulk_optimization_page() {
398
+ $stats = Tiny_Image::get_optimization_statistics( $this->settings );
399
  $estimated_costs = Tiny_Compress::estimate_cost(
400
  $stats['available-unoptimised-sizes'],
401
  $this->settings->get_compression_count()
src/class-tiny-settings.php CHANGED
@@ -256,7 +256,7 @@ class Tiny_Settings extends Tiny_WP_Base {
256
  if ( $width || $height ) {
257
  $this->sizes[ $size ] = array(
258
  'width' => $width,
259
- 'height' => $height,
260
  'tinify' => ! is_array( $setting ) ||
261
  ( isset( $setting[ $size ] ) && 'on' === $setting[ $size ] ),
262
  );
256
  if ( $width || $height ) {
257
  $this->sizes[ $size ] = array(
258
  'width' => $width,
259
+ 'height' => $height,
260
  'tinify' => ! is_array( $setting ) ||
261
  ( isset( $setting[ $size ] ) && 'on' === $setting[ $size ] ),
262
  );
test/unit/TinyImageDuplicateTest.php CHANGED
@@ -17,7 +17,7 @@ class Tiny_Image_Duplicate_Test extends Tiny_TestCase {
17
 
18
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
19
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
20
- $this->subject = new Tiny_Image( 1, $this->json( '_wp_attachment_metadata_duplicates' ) );
21
  }
22
 
23
  public function test_get_images_should_return_all_images() {
17
 
18
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
19
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
20
+ $this->subject = new Tiny_Image( new Tiny_Settings(), 1, $this->json( '_wp_attachment_metadata_duplicates' ) );
21
  }
22
 
23
  public function test_get_images_should_return_all_images() {
test/unit/TinyImageEmptyTest.php CHANGED
@@ -8,7 +8,7 @@ class Tiny_Image_Empty_Test extends Tiny_TestCase {
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, '' );
11
- $this->subject = new Tiny_Image( 1, $this->json( '_wp_attachment_metadata' ) );
12
  }
13
 
14
  public function test_get_savings() {
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, '' );
11
+ $this->subject = new Tiny_Image( new Tiny_Settings(), 1, $this->json( '_wp_attachment_metadata' ) );
12
  }
13
 
14
  public function test_get_savings() {
test/unit/TinyImageSizeTest.php CHANGED
@@ -8,7 +8,7 @@ class Tiny_Image_Size_Test extends Tiny_TestCase {
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
11
- $tiny_image = new Tiny_Image( 1, $this->json( '_wp_attachment_metadata' ) );
12
 
13
  $this->original = $tiny_image->get_image_size();
14
  $this->thumbnail = $tiny_image->get_image_size( 'thumbnail' );
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
11
+ $tiny_image = new Tiny_Image( new Tiny_Settings(), 1, $this->json( '_wp_attachment_metadata' ) );
12
 
13
  $this->original = $tiny_image->get_image_size();
14
  $this->thumbnail = $tiny_image->get_image_size( 'thumbnail' );
test/unit/TinyImageTest.php CHANGED
@@ -8,7 +8,7 @@ class Tiny_Image_Test extends Tiny_TestCase {
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
11
- $this->subject = new Tiny_Image( 1, $this->json( '_wp_attachment_metadata' ) );
12
  }
13
 
14
  public function test_tiny_post_meta_key_may_never_change() {
@@ -16,14 +16,14 @@ class Tiny_Image_Test extends Tiny_TestCase {
16
  }
17
 
18
  public function test_update_wp_metadata_should_not_update_with_no_resized_original() {
19
- $tiny_image = new Tiny_Image( 150, $this->json( '_wp_attachment_metadata' ) );
20
  $tiny_image_metadata = $tiny_image->get_wp_metadata();
21
  $this->assertEquals( 1256, $tiny_image_metadata['width'] );
22
  $this->assertEquals( 1256, $tiny_image_metadata['height'] );
23
  }
24
 
25
  public function test_update_wp_metadata_should_update_with_resized_original() {
26
- $tiny_image = new Tiny_Image( 150, $this->json( '_wp_attachment_metadata' ) );
27
  $response = array( 'output' => array( 'width' => 200, 'height' => 100 ) );
28
  $tiny_image->get_image_size()->add_tiny_meta_start();
29
  $tiny_image->get_image_size()->add_tiny_meta( $response );
@@ -118,7 +118,7 @@ class Tiny_Image_Test extends Tiny_TestCase {
118
  'unoptimized-library-size' => 328670,
119
  'available-for-optimization' => array( array( 'ID' => 1, 'post_title' => 'I am the one and only' ) ),
120
  ),
121
- Tiny_Image::get_optimization_statistics( $wpdb_results )
122
  );
123
  }
124
  }
8
 
9
  $this->wp->createImagesFromJSON( $this->json( 'image_filesystem_data' ) );
10
  $this->wp->setTinyMetadata( 1, $this->json( 'image_database_metadata' ) );
11
+ $this->subject = new Tiny_Image( new Tiny_Settings(), 1, $this->json( '_wp_attachment_metadata' ) );
12
  }
13
 
14
  public function test_tiny_post_meta_key_may_never_change() {
16
  }
17
 
18
  public function test_update_wp_metadata_should_not_update_with_no_resized_original() {
19
+ $tiny_image = new Tiny_Image( new Tiny_Settings(), 150, $this->json( '_wp_attachment_metadata' ) );
20
  $tiny_image_metadata = $tiny_image->get_wp_metadata();
21
  $this->assertEquals( 1256, $tiny_image_metadata['width'] );
22
  $this->assertEquals( 1256, $tiny_image_metadata['height'] );
23
  }
24
 
25
  public function test_update_wp_metadata_should_update_with_resized_original() {
26
+ $tiny_image = new Tiny_Image( new Tiny_Settings(), 150, $this->json( '_wp_attachment_metadata' ) );
27
  $response = array( 'output' => array( 'width' => 200, 'height' => 100 ) );
28
  $tiny_image->get_image_size()->add_tiny_meta_start();
29
  $tiny_image->get_image_size()->add_tiny_meta( $response );
118
  'unoptimized-library-size' => 328670,
119
  'available-for-optimization' => array( array( 'ID' => 1, 'post_title' => 'I am the one and only' ) ),
120
  ),
121
+ Tiny_Image::get_optimization_statistics( new Tiny_Settings(), $wpdb_results )
122
  );
123
  }
124
  }
test/unit/TinyPluginTest.php CHANGED
@@ -84,7 +84,7 @@ class Tiny_Plugin_Test extends Tiny_TestCase {
84
  $this->wp->stub( 'get_post_mime_type', create_function( '$i', 'return "image/png";' ) );
85
 
86
  $testmeta = $this->wp->getTestMetadata();
87
- $tiny_image = new Tiny_Image( 1, $testmeta );
88
  $tiny_image->get_image_size()->add_tiny_meta_start();
89
  $tiny_image->get_image_size()->add_tiny_meta( self::success_compress( 'vfs://root/wp-content/uploads/14/01/test.png' ) );
90
  $tiny_image->get_image_size( 'large' )->add_tiny_meta_start();
@@ -101,7 +101,7 @@ class Tiny_Plugin_Test extends Tiny_TestCase {
101
  $this->wp->stub( 'get_post_mime_type', create_function( '$i', 'return "image/png";' ) );
102
 
103
  $testmeta = $this->wp->getTestMetadata();
104
- $tiny_image = new Tiny_Image( 1, $testmeta );
105
  $tiny_image->get_image_size()->add_tiny_meta_start();
106
  $tiny_image->get_image_size()->add_tiny_meta( self::success_compress( 'vfs://root/wp-content/uploads/14/01/test.png' ) );
107
  $tiny_image->get_image_size( 'large' )->add_tiny_meta_start();
84
  $this->wp->stub( 'get_post_mime_type', create_function( '$i', 'return "image/png";' ) );
85
 
86
  $testmeta = $this->wp->getTestMetadata();
87
+ $tiny_image = new Tiny_Image( new Tiny_Settings(), 1, $testmeta );
88
  $tiny_image->get_image_size()->add_tiny_meta_start();
89
  $tiny_image->get_image_size()->add_tiny_meta( self::success_compress( 'vfs://root/wp-content/uploads/14/01/test.png' ) );
90
  $tiny_image->get_image_size( 'large' )->add_tiny_meta_start();
101
  $this->wp->stub( 'get_post_mime_type', create_function( '$i', 'return "image/png";' ) );
102
 
103
  $testmeta = $this->wp->getTestMetadata();
104
+ $tiny_image = new Tiny_Image( new Tiny_Settings(), 1, $testmeta );
105
  $tiny_image->get_image_size()->add_tiny_meta_start();
106
  $tiny_image->get_image_size()->add_tiny_meta( self::success_compress( 'vfs://root/wp-content/uploads/14/01/test.png' ) );
107
  $tiny_image->get_image_size( 'large' )->add_tiny_meta_start();
tiny-compress-images.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Compress JPEG & PNG images
4
  * Description: Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG.
5
- * Version: 2.0.1
6
  * Author: TinyPNG
7
  * Author URI: https://tinypng.com
8
  * Text Domain: tiny-compress-images
2
  /**
3
  * Plugin Name: Compress JPEG & PNG images
4
  * Description: Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG.
5
+ * Version: 2.0.2
6
  * Author: TinyPNG
7
  * Author URI: https://tinypng.com
8
  * Text Domain: tiny-compress-images