Compress JPEG & PNG images - Version 2.2.1

Version Description

  • Fixed an error that was introduced in v2.2.0 where all custom image sizes did not show up.
  • Added support for image sizes with unspecified height or width.
Download this release

Release Info

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

Code changes from version 2.2.0 to 2.2.1

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.7
7
- Stable tag: 2.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -31,6 +31,7 @@ Make your website faster by optimizing your JPEG and PNG images. This plugin aut
31
  * Color profiles are automatically translated to the standard RGB color space.
32
  * Convert CMYK to RGB to save more space and maximize compatibility.
33
  * Optimize and resize uploads with the WordPress mobile app.
 
34
  * No file size limits.
35
 
36
  = How does it work? =
@@ -109,6 +110,9 @@ A: Everything will keep on working, but newly uploaded images will not be optimi
109
  A: Yes! After installing the plugin, go to *Media > Bulk Optimization*, and click on the start button to optimize all unoptimized images in your media library.
110
 
111
  == Changelog ==
 
 
 
112
 
113
  = 2.2.0 =
114
  * New dashboard widget that shows your media library savings.
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.7
7
+ Stable tag: 2.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
31
  * Color profiles are automatically translated to the standard RGB color space.
32
  * Convert CMYK to RGB to save more space and maximize compatibility.
33
  * Optimize and resize uploads with the WordPress mobile app.
34
+ * Dashboard widget with your total savings.
35
  * No file size limits.
36
 
37
  = How does it work? =
110
  A: Yes! After installing the plugin, go to *Media > Bulk Optimization*, and click on the start button to optimize all unoptimized images in your media library.
111
 
112
  == Changelog ==
113
+ = 2.2.1 =
114
+ * Fixed an error that was introduced in v2.2.0 where all custom image sizes did not show up.
115
+ * Added support for image sizes with unspecified height or width.
116
 
117
  = 2.2.0 =
118
  * New dashboard widget that shows your media library savings.
src/class-tiny-plugin.php CHANGED
@@ -18,7 +18,7 @@
18
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
  */
20
  class Tiny_Plugin extends Tiny_WP_Base {
21
- const VERSION = '2.2.0';
22
  const MEDIA_COLUMN = self::NAME;
23
  const DATETIME_FORMAT = 'Y-m-d G:i:s';
24
 
18
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
  */
20
  class Tiny_Plugin extends Tiny_WP_Base {
21
+ const VERSION = '2.2.1';
22
  const MEDIA_COLUMN = self::NAME;
23
  const DATETIME_FORMAT = 'Y-m-d G:i:s';
24
 
src/class-tiny-settings.php CHANGED
@@ -220,8 +220,8 @@ class Tiny_Settings extends Tiny_WP_Base {
220
  $height = get_option( $size . '_size_h' );
221
 
222
  /* Note: dimensions might be 0 to indicate no limit. */
223
- if ( isset( $width ) && isset( $height ) ) {
224
- return array( $width, $height );
225
  }
226
 
227
  if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
@@ -425,8 +425,9 @@ class Tiny_Settings extends Tiny_WP_Base {
425
  Tiny_Config::MONTHLY_FREE_COMPRESSIONS / $active_sizes_count
426
  );
427
  printf( wp_kses( __(
428
- 'With these settings you can compress
429
- <strong> at least %s images </strong> for free each month.',
 
430
  'tiny-compress-images'
431
  ), array( 'strong' => array() ) ), $free_images_per_month );
432
 
220
  $height = get_option( $size . '_size_h' );
221
 
222
  /* Note: dimensions might be 0 to indicate no limit. */
223
+ if ( $width || $height ) {
224
+ return array( $width, $height );
225
  }
226
 
227
  if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
425
  Tiny_Config::MONTHLY_FREE_COMPRESSIONS / $active_sizes_count
426
  );
427
  printf( wp_kses( __(
428
+ 'With these settings you can compress '
429
+ . '<strong>at least %s images</strong>'
430
+ . ' for free each month.',
431
  'tiny-compress-images'
432
  ), array( 'strong' => array() ) ), $free_images_per_month );
433
 
src/views/bulk-optimization.php CHANGED
@@ -140,15 +140,10 @@ div.tiny-bulk-optimization div.dashboard div.optimize div.progressbar div.progre
140
  <div class="tooltip">
141
  <span class="dashicons dashicons-info"></span>
142
  <div class="tip">
143
- <p>
144
- <?php esc_html_e( 'If you wish to compress more than ', 'tiny-compress-images' ) ?>
145
- <strong>
146
- <?php echo Tiny_Config::MONTHLY_FREE_COMPRESSIONS ?>
147
- <?php esc_html_e( 'image sizes', 'tiny-compress-images' ) ?>
148
- </strong>
149
- <?php esc_html_e( 'a month and you are still on a free account', 'tiny-compress-images' ) ?>
150
- <a href="https://tinypng.com/developers"><?php esc_html_e( 'upgrade here.', 'tiny-compress-images' ) ?></a>
151
- </p>
152
  </div>
153
  </div>
154
  <?php } ?>
140
  <div class="tooltip">
141
  <span class="dashicons dashicons-info"></span>
142
  <div class="tip">
143
+ <p><?php
144
+ printf( wp_kses( __( 'If you wish to compress more than <strong>%d %s</strong> a month and you are still on a free account %s.', 'tiny-compress-images' ),
145
+ array( 'strong' => array(), 'a' => array( 'href' => array() ) ) ), Tiny_Config::MONTHLY_FREE_COMPRESSIONS, esc_html__( 'image sizes', 'tiny-compress-images' ), '<a href="https://tinypng.com/dashboard/developers">' . esc_html__( ' upgrade here', 'tiny-compress-images' ) . '</a>' );
146
+ ?></p>
 
 
 
 
 
147
  </div>
148
  </div>
149
  <?php } ?>
src/views/dashboard-widget.php CHANGED
@@ -31,7 +31,7 @@ div#optimization-chart {
31
  </div>
32
  <div class="media-library-optimized" id="widget-full-optimized">
33
  <p><?php printf( esc_html__( '%s, this is great! Your entire library is optimized!', 'tiny-compress-images' ), $this->friendly_user_name() ) ?></p>
34
- <p id="ie8-compressed"><?php printf( wp_kses( __( 'You have compressed <span></span>%% of your media library.', 'tiny-compress-images' ), array( 'span' => array() ) ) )?></p>
35
  </div>
36
  <div class="media-library-optimized" id="widget-half-optimized">
37
  <p>
31
  </div>
32
  <div class="media-library-optimized" id="widget-full-optimized">
33
  <p><?php printf( esc_html__( '%s, this is great! Your entire library is optimized!', 'tiny-compress-images' ), $this->friendly_user_name() ) ?></p>
34
+ <p id="ie8-compressed"><?php printf( wp_kses( __( 'You have <strong>saved %s</strong> of your media library size.', 'tiny-compress-images' ), array( 'span' => array(), 'strong' => array() ) ), '<span></span>%' )?></p>
35
  </div>
36
  <div class="media-library-optimized" id="widget-half-optimized">
37
  <p>
test/integration/DashboardWidgetIntegrationTest.php CHANGED
@@ -48,17 +48,11 @@ class DashboardWidgetIntegrationTest extends IntegrationTestCase {
48
  $element = $this->find(
49
  '#tinypng_dashboard_widget #widget-half-optimized p'
50
  );
51
- if ( $this->has_medium_large_size() ) {
52
- $this->assertEquals(
53
- 'Admin, you are doing good. With your current settings you can still optimize 5 image sizes from your 2 uploaded JPEG and PNG images. Start the bulk optimization to optimize the remainder of your library.',
54
- $element->getText()
55
- );
56
- } else {
57
- $this->assertEquals(
58
- 'Admin, you are doing good. With your current settings you can still optimize 4 image sizes from your 2 uploaded JPEG and PNG images. Start the bulk optimization to optimize the remainder of your library.',
59
- $element->getText()
60
- );
61
- }
62
  }
63
 
64
  public function test_should_show_widget_with_all_images_optimized() {
48
  $element = $this->find(
49
  '#tinypng_dashboard_widget #widget-half-optimized p'
50
  );
51
+
52
+ $this->assertContains(
53
+ 'Admin, you are doing good. With your current settings you can still optimize',
54
+ $element->getText()
55
+ );
 
 
 
 
 
 
56
  }
57
 
58
  public function test_should_show_widget_with_all_images_optimized() {
test/unit/TinySettingsTest.php CHANGED
@@ -79,6 +79,30 @@ class Tiny_Settings_Test extends Tiny_TestCase {
79
  ), $this->subject->get_sizes());
80
  }
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  public function test_should_skip_dummy_size() {
83
  $this->wp->addOption( 'tinypng_sizes[tiny_dummy]', 'on' );
84
 
79
  ), $this->subject->get_sizes());
80
  }
81
 
82
+ public function test_should_not_retrieve_sizes_with_zero_width_and_height_values() {
83
+ $this->wp->addOption( 'tinypng_sizes[0]', 'on' );
84
+ $this->wp->addOption( 'tinypng_sizes[medium]', 'on' );
85
+ $this->wp->addOption( 'tinypng_sizes[post-thumbnail]', 'on' );
86
+ $this->wp->addOption( 'tinypng_sizes[zero-width]', 'off' );
87
+ $this->wp->addOption( 'tinypng_sizes[zero-height]', 'off' );
88
+ $this->wp->addOption( 'tinypng_sizes[zero-width-height]', 'off' );
89
+
90
+ $this->wp->addImageSize( 'zero-width', array( 'width' => 0, 'height' => 510 ) );
91
+ $this->wp->addImageSize( 'zero-height', array( 'width' => 825, 'height' => 0 ) );
92
+ $this->wp->addImageSize( 'zero-width-height', array( 'width' => 0, 'height' => 0 ) );
93
+
94
+ $this->subject->get_sizes();
95
+ $this->assertEquals(array(
96
+ 0 => array( 'width' => null, 'height' => null, 'tinify' => true ),
97
+ 'thumbnail' => array( 'width' => 150, 'height' => 150, 'tinify' => false ),
98
+ 'medium' => array( 'width' => 300, 'height' => 300, 'tinify' => true ),
99
+ 'medium_large' => array( 'width' => 768, 'height' => 0, 'tinify' => false ),
100
+ 'large' => array( 'width' => 1024, 'height' => 1024, 'tinify' => false ),
101
+ 'zero-width' => array( 'width' => 0, 'height' => 510, 'tinify' => false ),
102
+ 'zero-height' => array( 'width' => 825, 'height' => 0, 'tinify' => false )
103
+ ), $this->subject->get_sizes());
104
+ }
105
+
106
  public function test_should_skip_dummy_size() {
107
  $this->wp->addOption( 'tinypng_sizes[tiny_dummy]', 'on' );
108
 
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.2.0
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.2.1
6
  * Author: TinyPNG
7
  * Author URI: https://tinypng.com
8
  * Text Domain: tiny-compress-images