Compress JPEG & PNG images - Version 1.3.2

Version Description

  • In some cases a user would have different file sizes defined in Settings > Media which have the exact same pixel dimensions. Compressing images could then occasionally result in compressing the same image multiple times without being seen as 'compressed'. We now detect duplicate file sizes and don't compress them again.
Download this release

Release Info

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

Code changes from version 1.3.0 to 1.3.2

.travis.yml CHANGED
@@ -8,5 +8,6 @@ php:
8
  before_script: composer install
9
  script: bin/unit-tests
10
  notifications:
 
11
  slack:
12
  secure: uttJ78cpkV9czhoKXtAoop8UBWPVtF+fwKlKS47c4EW7ZfVx9jAII2yLb5yZjdLDnM7YAluujUBIqyESvwLY0h7azLsorSIEqNt9GlBi4B7DSGAdo46lFbqsdjrLwM1gOhiP7Fl4hFiQ2+jA9Fsj3W2yZ6rbF7endv7Gx5FMlFg=
8
  before_script: composer install
9
  script: bin/unit-tests
10
  notifications:
11
+ email: false
12
  slack:
13
  secure: uttJ78cpkV9czhoKXtAoop8UBWPVtF+fwKlKS47c4EW7ZfVx9jAII2yLb5yZjdLDnM7YAluujUBIqyESvwLY0h7azLsorSIEqNt9GlBi4B7DSGAdo46lFbqsdjrLwM1gOhiP7Fl4hFiQ2+jA9Fsj3W2yZ6rbF7endv7Gx5FMlFg=
README.md CHANGED
@@ -1,4 +1,4 @@
1
- [<img src="https://travis-ci.org/TinyPNG/wordpress-plugin.svg?branch=master" alt="Build Status">](https://travis-ci.org/TinyPNG/wordpress-plugin)
2
 
3
  # TinyPNG image compression for WordPress
4
  Make your website faster by compressing your JPEG and PNG images.
@@ -28,9 +28,9 @@ Got questions or feedback? Let us know! Contact us at support@tinypng.com.
28
 
29
  ### Running the integration tests
30
  1. Start Selenium server: `java -jar selenium-server-standalone-2.44.0.jar`.
31
- 2. Run `bin/integration-tests $version [$to_version]`. E.g. `bin/run-wordpress 41` or `bin/integration-tests 40 42`.
32
-
33
- Note that when testing a different WordPress version, `bin/run-wordpress <version>` has to be run first.
34
 
35
  ## License
36
  Copyright (C) 2015 Voormedia B.V.
1
+ [<img src="https://travis-ci.org/tinify/wordpress-plugin.svg?branch=master" alt="Build Status">](https://travis-ci.org/tinify/wordpress-plugin)
2
 
3
  # TinyPNG image compression for WordPress
4
  Make your website faster by compressing your JPEG and PNG images.
28
 
29
  ### Running the integration tests
30
  1. Start Selenium server: `java -jar selenium-server-standalone-2.44.0.jar`.
31
+ 2. Run `bin/integration-tests $version [$to_version]` (When $to_version is
32
+ added, all versions between $version and $to_version are tested). E.g.
33
+ `bin/integration-tests 41` or `bin/integration-tests 40 42`.
34
 
35
  ## License
36
  Copyright (C) 2015 Voormedia B.V.
RELEASE CHANGED
@@ -2,14 +2,15 @@ In order to release a new version of the plugin to wordpress.org, perform the fo
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. Commit and push to GitHub.
6
- 4. Create a new release in GitHub and pull it in.
7
- 5. Locally, checkout the new tag: `git checkout <tagged version>`.
8
- 6. If not already done so, checkout the plugin's Subversion repository: `svn co http://plugins.svn.wordpress.org/tiny-compress-images`.
9
- 7. Update svn:ignore property of trunk when .gitignore is updated: `svn propedit svn:ignore trunk`.
10
- 8. Delete everything in trunk `rm -rf <path-to-local-svn-repo/trunk/*`.
11
- 9. Manually copy the Git release to the local Subversion repo: `git ls-files | xargs tar c | tar x -C <path-to-local-svn-repo>/trunk/`.
12
- 10. Add new files `svn st | awk '/^\?/ { print $2; }' | xargs svn add`.
13
- 11. Delete deleted files: `svn st | awk '/^!/ { print $2; }' | xargs svn rm`.
14
- 12. Commit the trunk to Subversion: `svn ci -m "<message>"`.
15
- 13. Tag the new release in Subversion and commit: `svn cp trunk tags/<version> && svn ci -m "<message>"`.
 
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. If you've changed the plugin to work with newer version of wordpress add that to the readme as well.
6
+ 4. Commit and push to GitHub.
7
+ 5. Create a new release in GitHub and pull it in.
8
+ 6. Locally, checkout the new tag: `git checkout <tagged version>`.
9
+ 7. If not already done so, checkout the plugin's Subversion repository: `svn co http://plugins.svn.wordpress.org/tiny-compress-images`.
10
+ 8. Update svn:ignore property of trunk when .gitignore is updated: `svn propedit svn:ignore trunk`.
11
+ 9. Delete everything in trunk `rm -rf <path-to-local-svn-repo/trunk/*`.
12
+ 10. Manually copy the Git release to the local Subversion repo: `git ls-files | xargs tar c | tar x -C <path-to-local-svn-repo>/trunk/`.
13
+ 11. Add new files `svn st | awk '/^\?/ { print $2; }' | xargs svn add`.
14
+ 12. Delete deleted files: `svn st | awk '/^!/ { print $2; }' | xargs svn rm`.
15
+ 13. Commit the trunk to Subversion: `svn ci -m "<message>"`.
16
+ 14. Tag the new release in Subversion and commit: `svn cp trunk tags/<version> && svn ci -m "<message>"`.
bin/integration-tests CHANGED
@@ -7,7 +7,13 @@ use IO::Socket;
7
  use Time::HiRes qw(usleep);
8
 
9
  my $dir = dirname($0);
10
- my $hostip = `boot2docker ip`;
 
 
 
 
 
 
11
 
12
  sub check_port {
13
  my ($ip, $port, $times, $sleep) = @_;
7
  use Time::HiRes qw(usleep);
8
 
9
  my $dir = dirname($0);
10
+
11
+ my $hostip;
12
+ if (`which docker-machine`) {
13
+ $hostip = `docker-machine ip default`;
14
+ } else {
15
+ $hostip = `boot2docker ip`;
16
+ }
17
 
18
  sub check_port {
19
  my ($ip, $port, $times, $sleep) = @_;
bin/restore-wordpress CHANGED
@@ -19,7 +19,13 @@ source $DIR/docker-functions
19
  export WORDPRESS_VERSION=$version
20
  export WORDPRESS_DATABASE=wordpress_$version
21
  export MYSQL_ROOT_PASSWORD=root
22
- export HOST_IP=$(boot2docker ip)
 
 
 
 
 
 
23
  export MYSQL_DUMP_FILE=tmp/mysqldump_wordpress_$version.sql.gz
24
 
25
  gunzip -c < $MYSQL_DUMP_FILE | mysql -h $HOST_IP -u root "-p$MYSQL_ROOT_PASSWORD" $WORDPRESS_DATABASE
19
  export WORDPRESS_VERSION=$version
20
  export WORDPRESS_DATABASE=wordpress_$version
21
  export MYSQL_ROOT_PASSWORD=root
22
+
23
+ if hash docker-machine 2>/dev/null; then
24
+ export HOST_IP=$(docker-machine ip default)
25
+ else
26
+ export HOST_IP=$(boot2docker ip)
27
+ fi
28
+
29
  export MYSQL_DUMP_FILE=tmp/mysqldump_wordpress_$version.sql.gz
30
 
31
  gunzip -c < $MYSQL_DUMP_FILE | mysql -h $HOST_IP -u root "-p$MYSQL_ROOT_PASSWORD" $WORDPRESS_DATABASE
bin/test-wordpress CHANGED
@@ -26,7 +26,13 @@ fi
26
  export WORDPRESS_VERSION=$version
27
  export WORDPRESS_DATABASE=wordpress_$version
28
  export MYSQL_ROOT_PASSWORD=root
29
- export HOST_IP=$(boot2docker ip)
 
 
 
 
 
 
30
  export HOST_PORT=80$version
31
- export WORDPRESS_URL=http://$(boot2docker ip):$HOST_PORT
32
  vendor/bin/phpunit "$PHPUNIT_ARG"
26
  export WORDPRESS_VERSION=$version
27
  export WORDPRESS_DATABASE=wordpress_$version
28
  export MYSQL_ROOT_PASSWORD=root
29
+
30
+ if hash docker-machine 2>/dev/null; then
31
+ export HOST_IP=$(docker-machine ip default)
32
+ else
33
+ export HOST_IP=$(boot2docker ip)
34
+ fi
35
+
36
  export HOST_PORT=80$version
37
+ export WORDPRESS_URL=http://$HOST_IP:$HOST_PORT
38
  vendor/bin/phpunit "$PHPUNIT_ARG"
config/Dockerfile-phantomjs CHANGED
@@ -1,17 +1,5 @@
1
- FROM ubuntu:14.04
2
 
3
  EXPOSE 8910
4
 
5
- ENV PHANTOM_JS_VERSION 1.9.7-linux-x86_64
6
-
7
- RUN apt-get update
8
- RUN apt-get install -yqq curl libfreetype6 libfontconfig
9
- # make ruby python git g++ flex bison gperf perl \
10
- # libfontconfig1-dev libicu-dev libfreetype6 \
11
- # libssl-dev libpng-dev libjpeg-dev
12
- # RUN git clone git://github.com/ariya/phantomjs.git && cd phantomjs && ./build.sh && send "y\n"
13
-
14
- RUN curl -sSL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION.tar.bz2 | tar xjC /
15
- RUN ln -s phantomjs-$PHANTOM_JS_VERSION /phantomjs
16
-
17
- CMD ["/phantomjs/bin/phantomjs", "--webdriver=8910"]
1
+ FROM servebox/phantomjs:latest
2
 
3
  EXPOSE 8910
4
 
5
+ CMD ["phantomjs", "--webdriver=8910"]
 
 
 
 
 
 
 
 
 
 
 
 
config/Dockerfile-wordpress-37 CHANGED
@@ -2,9 +2,9 @@ FROM wordpress:4
2
 
3
  RUN docker-php-ext-install mysql
4
 
5
- ENV WORDPRESS_VERSION 3.7.8
6
- ENV WORDPRESS_UPSTREAM_VERSION 3.7.8
7
- ENV WORDPRESS_SHA1 f6a326bc7fe8805a142d3c3e5db7857c336d8a75
8
 
9
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
10
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
2
 
3
  RUN docker-php-ext-install mysql
4
 
5
+ ENV WORDPRESS_VERSION 3.7.11
6
+ ENV WORDPRESS_UPSTREAM_VERSION 3.7.11
7
+ ENV WORDPRESS_SHA1 7b331b23756520beee83fa1530a1e43bf510b5c5
8
 
9
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
10
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-38 CHANGED
@@ -2,9 +2,9 @@ FROM wordpress:4
2
 
3
  RUN docker-php-ext-install mysql
4
 
5
- ENV WORDPRESS_VERSION 3.8.8
6
- ENV WORDPRESS_UPSTREAM_VERSION 3.8.8
7
- ENV WORDPRESS_SHA1 8c5875ae76cdc9fb545e9e30591c67021bb1fafd
8
 
9
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
10
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
2
 
3
  RUN docker-php-ext-install mysql
4
 
5
+ ENV WORDPRESS_VERSION 3.8.11
6
+ ENV WORDPRESS_UPSTREAM_VERSION 3.8.11
7
+ ENV WORDPRESS_SHA1 d58349c2aea01aa97ce4452bfe62347a9b82d28a
8
 
9
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
10
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-39 CHANGED
@@ -1,8 +1,8 @@
1
  FROM wordpress:4
2
 
3
- ENV WORDPRESS_VERSION 3.9.6
4
- ENV WORDPRESS_UPSTREAM_VERSION 3.9.6
5
- ENV WORDPRESS_SHA1 373c185080d0e3b2cd748277d013894e8a3af0d9
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
1
  FROM wordpress:4
2
 
3
+ ENV WORDPRESS_VERSION 3.9.9
4
+ ENV WORDPRESS_UPSTREAM_VERSION 3.9.9
5
+ ENV WORDPRESS_SHA1 559edda1c178879d73ad234b098b8080506fbd71
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-40 CHANGED
@@ -1,8 +1,8 @@
1
  FROM wordpress:4
2
 
3
- ENV WORDPRESS_VERSION 4.0.5
4
- ENV WORDPRESS_UPSTREAM_VERSION 4.0.5
5
- ENV WORDPRESS_SHA1 23de8e24ea68a19723b6ebc95f44c8d32df97a8e
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
1
  FROM wordpress:4
2
 
3
+ ENV WORDPRESS_VERSION 4.0.8
4
+ ENV WORDPRESS_UPSTREAM_VERSION 4.0.8
5
+ ENV WORDPRESS_SHA1 6a3511025d9b9ccfec45efdad27d67a85ecce595
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-41 CHANGED
@@ -1,8 +1,8 @@
1
  FROM wordpress:4
2
 
3
- ENV WORDPRESS_VERSION 4.1.5
4
- ENV WORDPRESS_UPSTREAM_VERSION 4.1.5
5
- ENV WORDPRESS_SHA1 85bc3f20d0ee8c98f9eabeba48eb37fe732eab33
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
1
  FROM wordpress:4
2
 
3
+ ENV WORDPRESS_VERSION 4.1.8
4
+ ENV WORDPRESS_UPSTREAM_VERSION 4.1.8
5
+ ENV WORDPRESS_SHA1 f3dc8f554312eeee5145c7eaaf85506e01a3d738
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-42 CHANGED
@@ -1,8 +1,8 @@
1
  FROM wordpress:4
2
 
3
- ENV WORDPRESS_VERSION 4.2.2
4
- ENV WORDPRESS_UPSTREAM_VERSION 4.2.2
5
- ENV WORDPRESS_SHA1 d3a70d0f116e6afea5b850f793a81a97d2115039
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
1
  FROM wordpress:4
2
 
3
+ ENV WORDPRESS_VERSION 4.2.5
4
+ ENV WORDPRESS_UPSTREAM_VERSION 4.2.5
5
+ ENV WORDPRESS_SHA1 a8944f75f51b4687648a9a272e15dc17b9e25577
6
 
7
  # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
  RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
config/Dockerfile-wordpress-43 ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM wordpress:4
2
+
3
+ ENV WORDPRESS_VERSION 4.3.1
4
+ ENV WORDPRESS_UPSTREAM_VERSION 4.3.1
5
+ ENV WORDPRESS_SHA1 b2e5652a6d2333cabe7b37459362a3e5b8b66221
6
+
7
+ # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
8
+ RUN curl -o wordpress.tar.gz -sSL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
9
+ && echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \
10
+ && tar -xzf wordpress.tar.gz -C /usr/src/ \
11
+ && rm wordpress.tar.gz \
12
+ && chown -R www-data:www-data /usr/src/wordpress
13
+
14
+ ENTRYPOINT ["/entrypoint.sh"]
15
+ CMD ["apache2-foreground"]
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: TinyPNG
3
  Donate link: https://tinypng.com/
4
  Tags: compress, optimize, shrink, improve, images, tinypng, tinyjpg, jpeg, jpg, png, lossy, jpegmini, crunch, minify, smush, save, bandwidth, website, speed, faster, performance, panda
5
  Requires at least: 3.0.6
6
- Tested up to: 4.2
7
- Stable tag: 1.3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,17 +12,28 @@ Speed up your website. Optimize your JPEG and PNG images automatically with Tin
12
 
13
  == Description ==
14
 
15
- Make your website faster by compressing your JPEG and PNG images.
16
 
17
- This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  = How does it work? =
20
 
21
- After you upload an image to your WordPress site, each resized image is uploaded to the TinyJPG or TinyPNG service. Your image is analyzed to apply the best possible compression. Based on the content of your image an optimal strategy is chosen. The result is sent back to your WordPress site. On average JPEG images are compressed by 40-60% and PNG images by 50-80% without visible loss in quality. Your website will load faster for your visitors, and you’ll save storage space and bandwidth!
22
 
23
  = Getting started =
24
 
25
- Install this plugin and obtain your free API key from https://tinypng.com/developers. The first 500 compressions per month are completely free, so roughly 100 images can be uploaded to WordPress for free, no strings attached! You can also change which of the generated thumbnail sizes should be compressed, because each one of them counts as a compression. And if you’re a heavy user, you can compress additional images for a small additional fee per image.
26
 
27
  = Multisite support =
28
 
@@ -34,7 +45,7 @@ Got questions or feedback? Let us know! Contact us at support@tinypng.com or fin
34
 
35
  = Contributors =
36
 
37
- Want to contribute? Checkout our [GitHub page](https://github.com/TinyPNG/wordpress-plugin).
38
 
39
  == Installation ==
40
 
@@ -68,8 +79,31 @@ The API key can also be configured in wp-config.php. You can add a TINY_API_KEY
68
  4. Show progress while bulk compressing (selection from) media library.
69
  5. Bulk compress complete media library.
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  == Changelog ==
72
 
 
 
 
 
 
 
73
  = 1.3.0 =
74
  * Improved bulk compressions from media library. You can now also bulk compress your whole media library in one step.
75
  * Intelligent detection if file is already compressed or was altered by another plugin and should be recompressed.
3
  Donate link: https://tinypng.com/
4
  Tags: compress, optimize, shrink, improve, images, tinypng, tinyjpg, jpeg, jpg, png, lossy, jpegmini, crunch, minify, smush, save, bandwidth, website, speed, faster, performance, panda
5
  Requires at least: 3.0.6
6
+ Tested up to: 4.3
7
+ Stable tag: 1.3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ Make your website faster by compressing your JPEG and PNG images. This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.
16
 
17
+ = Features =
18
+
19
+ * Automatically compress new images.
20
+ * Easy bulk compression of your existing media library.
21
+ * Compress individual images already in your media library.
22
+ * Multisite support with a single API key.
23
+ * Color profiles are translated to the standard RGB color space.
24
+ * See your usage directly from the media settings and during bulk compression.
25
+ * Select which thumbnail sizes of an image may be compressed.
26
+ * Converts from CMYK to RGB to save more space and maximize compatibility.
27
+ * Automatic detection of images that can be recompressed.
28
+ * No file size limit.
29
 
30
  = How does it work? =
31
 
32
+ After you upload an image to your WordPress site, each resized image is uploaded to the TinyJPG or TinyPNG service. Your image is analyzed to apply the best possible compression. Based on the content of your image an optimal strategy is chosen. The result is sent back to your WordPress site and will replace the original image with one smaller in size. On average JPEG images are compressed by 40-60% and PNG images by 50-80% without visible loss in quality. Your website will load faster for your visitors, and you’ll save storage space and bandwidth!
33
 
34
  = Getting started =
35
 
36
+ Install this plugin and obtain your free API key from https://tinypng.com/developers. The first 500 compressions per month are completely free, so roughly 100 images can be uploaded to WordPress for free, no strings attached! You can also change which of the generated thumbnail sizes should be compressed, because each one of them counts as a compression. And if you’re a heavy user, you can compress more than 500 images per month for a small additional fee per image.
37
 
38
  = Multisite support =
39
 
45
 
46
  = Contributors =
47
 
48
+ Want to contribute? Checkout our [GitHub page](https://github.com/tinify/wordpress-plugin).
49
 
50
  == Installation ==
51
 
79
  4. Show progress while bulk compressing (selection from) media library.
80
  5. Bulk compress complete media library.
81
 
82
+ == Frequently Asked Questions ==
83
+
84
+ = Q: I don't recall uploading 500 photos this month but my limit is already reached. How is this number calculated? =
85
+ A: When you upload an image to your website, Wordpress will create different sized versions of it (see Settings > Media). The plugin will compress each of these sizes, so when you have 100 images and 5 different sizes you will do 500 compressions.
86
+
87
+ = Q: What happens to the compressed images when I uninstall the plugin? =
88
+ A: When you remove the TinyPNG plugin all your compressed images will remain compressed.
89
+
90
+ = Q: Is there a file size limit? =
91
+ A: No. There are no limitations on the size of the images you want to compress.
92
+
93
+ = Q: What happens when I reach my monthly compression limit? =
94
+ A: Everything will keep on working, but newly uploaded images will not be compressed. Of course we encourage everyone to sign up for a full subscription.
95
+
96
+ = Q: Can I compress all existing images in my media library? =
97
+ A: Yes! After installing the plugin, go to Tools > Compress JPEG & PNG images, and click on "Compress all images" to compress all uncompressed images in your media library.
98
+
99
  == Changelog ==
100
 
101
+ = 1.3.2 =
102
+ * In some cases a user would have different file sizes defined in Settings > Media which have the exact same pixel dimensions. Compressing images could then occasionally result in compressing the same image multiple times without being seen as 'compressed'. We now detect duplicate file sizes and don't compress them again.
103
+
104
+ = 1.3.1 =
105
+ * Media library now shows when files are in the process of being compressed.
106
+
107
  = 1.3.0 =
108
  * Improved bulk compressions from media library. You can now also bulk compress your whole media library in one step.
109
  * Intelligent detection if file is already compressed or was altered by another plugin and should be recompressed.
src/class-tiny-compress-curl.php CHANGED
@@ -47,19 +47,20 @@ class Tiny_Compress_Curl extends Tiny_Compress {
47
 
48
  $output_url = null;
49
  $response = curl_exec($request);
50
- if ($response === false) {
51
  return array(array(
52
  'error' => 'CurlError',
53
- 'message' => sprintf("%s [%d]", curl_error($request), curl_errno($request))
54
  ), null
55
  );
56
  }
57
 
58
  $header_size = curl_getinfo($request, CURLINFO_HEADER_SIZE);
 
59
  $headers = self::parse_headers(substr($response, 0, $header_size));
60
  curl_close($request);
61
 
62
- return array(self::decode(substr($response, $header_size)), $headers);
63
  }
64
 
65
  protected function output_options($url) {
47
 
48
  $output_url = null;
49
  $response = curl_exec($request);
50
+ if ($response === false || $response === null) {
51
  return array(array(
52
  'error' => 'CurlError',
53
+ 'message' => sprintf("cURL: %s [%d]", curl_error($request), curl_errno($request))
54
  ), null
55
  );
56
  }
57
 
58
  $header_size = curl_getinfo($request, CURLINFO_HEADER_SIZE);
59
+ $status_code = curl_getinfo($request, CURLINFO_HTTP_CODE);
60
  $headers = self::parse_headers(substr($response, 0, $header_size));
61
  curl_close($request);
62
 
63
+ return array(self::decode(substr($response, $header_size)), $headers, $status_code);
64
  }
65
 
66
  protected function output_options($url) {
src/class-tiny-compress-fopen.php CHANGED
@@ -41,11 +41,20 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
41
  $context = stream_context_create($this->shrink_options($input));
42
  $request = @fopen(Tiny_Config::URL, 'r', false, $context);
43
 
 
 
 
 
 
 
 
 
44
  if (!$request) {
 
45
  return array(array(
46
  'error' => 'FopenError',
47
- 'message' => 'Could not compress, enable cURL for detailed error'
48
- ), null
49
  );
50
  }
51
 
@@ -54,7 +63,7 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
54
  $headers = self::parse_headers($meta_data['wrapper_data']);
55
  fclose($request);
56
 
57
- return array(self::decode($response), $headers);
58
  }
59
 
60
  protected function output_options() {
@@ -82,8 +91,4 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
82
 
83
  return $response;
84
  }
85
-
86
- public function get_status(&$details) {
87
- return null;
88
- }
89
  }
41
  $context = stream_context_create($this->shrink_options($input));
42
  $request = @fopen(Tiny_Config::URL, 'r', false, $context);
43
 
44
+ $status_code = null;
45
+ if ($http_response_header && count($http_response_header) > 0) {
46
+ $http_code_values = explode(' ', $http_response_header[0]);
47
+ if (count($http_code_values) > 1) {
48
+ $status_code = intval($http_code_values[1]);
49
+ }
50
+ }
51
+
52
  if (!$request) {
53
+ $headers = self::parse_headers($http_response_header);
54
  return array(array(
55
  'error' => 'FopenError',
56
+ 'message' => 'Could not compress, enable cURL for detailed error',
57
+ ), $headers, $status_code
58
  );
59
  }
60
 
63
  $headers = self::parse_headers($meta_data['wrapper_data']);
64
  fclose($request);
65
 
66
+ return array(self::decode($response), $headers, $status_code);
67
  }
68
 
69
  protected function output_options() {
91
 
92
  return $response;
93
  }
 
 
 
 
94
  }
src/class-tiny-compress.php CHANGED
@@ -44,10 +44,10 @@ abstract class Tiny_Compress {
44
  abstract protected function output($url);
45
 
46
  public function get_status(&$details) {
47
- list($details, $headers) = $this->shrink(null);
48
 
49
  $this->call_after_compress_callback($details, $headers);
50
- if (!isset($details['error']) || $details["error"] == 'InputMissing' || $details["error"] == 'TooManyRequests') {
51
  return true;
52
  } else {
53
  return false;
@@ -72,7 +72,7 @@ abstract class Tiny_Compress {
72
 
73
  public function compress_file($file) {
74
  if (!file_exists($file)) {
75
- throw new Tiny_Exception('File does not exists', 'FileError');
76
  }
77
  list($output, $details) = $this->compress(file_get_contents($file));
78
  file_put_contents($file, $output);
@@ -102,7 +102,10 @@ abstract class Tiny_Compress {
102
  protected static function decode($text) {
103
  $result = json_decode($text, true);
104
  if ($result === null) {
105
- throw new Tiny_Exception('Could not decode JSON', 'JsonError');
 
 
 
106
  }
107
  return $result;
108
  }
44
  abstract protected function output($url);
45
 
46
  public function get_status(&$details) {
47
+ list($details, $headers, $status_code) = $this->shrink(null);
48
 
49
  $this->call_after_compress_callback($details, $headers);
50
+ if ($status_code >= 400 && $status_code < 500 && $status_code != 401) {
51
  return true;
52
  } else {
53
  return false;
72
 
73
  public function compress_file($file) {
74
  if (!file_exists($file)) {
75
+ throw new Tiny_Exception('File does not exist', 'FileError');
76
  }
77
  list($output, $details) = $this->compress(file_get_contents($file));
78
  file_put_contents($file, $output);
102
  protected static function decode($text) {
103
  $result = json_decode($text, true);
104
  if ($result === null) {
105
+ throw new Tiny_Exception(sprintf('JSON: %s [%d]',
106
+ PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Error',
107
+ json_last_error()),
108
+ 'JsonError');
109
  }
110
  return $result;
111
  }
src/class-tiny-metadata.php CHANGED
@@ -58,10 +58,17 @@ class Tiny_Metadata {
58
 
59
  $this->filenames[self::ORIGINAL] = "$path_prefix${path_info['basename']}";
60
  $this->urls[self::ORIGINAL] = "$url_prefix${path_info['basename']}";
 
 
61
  if (isset($wp_metadata['sizes']) && is_array($wp_metadata['sizes'])) {
62
  foreach ($wp_metadata['sizes'] as $size => $info) {
63
- $this->filenames[$size] = "$path_prefix${info['file']}";
64
- $this->urls[$size] = "$url_prefix${info['file']}";
 
 
 
 
 
65
  }
66
  }
67
  }
@@ -71,10 +78,17 @@ class Tiny_Metadata {
71
  }
72
 
73
  public function add_response($response, $size=self::ORIGINAL) {
74
- $this->values[$size] = array(
75
  'input' => array('size' => $response['input']['size']),
76
  'output' => array('size' => $response['output']['size']),
77
- 'timestamp' => time()
 
 
 
 
 
 
 
78
  );
79
  }
80
 
@@ -108,6 +122,11 @@ class Tiny_Metadata {
108
  && file_exists($filename) && filesize($filename) == $this->values[$size]['output']['size'];
109
  }
110
 
 
 
 
 
 
111
  public function get_sizes() {
112
  return array_keys($this->filenames);
113
  }
@@ -116,11 +135,15 @@ class Tiny_Metadata {
116
  return array_filter(array_keys($this->values), array($this, 'is_compressed'));
117
  }
118
 
119
- public function get_missing_sizes($tinify_sizes) {
120
- $sizes = array_intersect($this->get_sizes(), $tinify_sizes);
121
  return array_diff($sizes, $this->get_success_sizes());
122
  }
123
 
 
 
 
 
124
  public function get_latest_error() {
125
  $last_time = null;
126
  $message = null;
58
 
59
  $this->filenames[self::ORIGINAL] = "$path_prefix${path_info['basename']}";
60
  $this->urls[self::ORIGINAL] = "$url_prefix${path_info['basename']}";
61
+
62
+ $unique_sizes = array();
63
  if (isset($wp_metadata['sizes']) && is_array($wp_metadata['sizes'])) {
64
  foreach ($wp_metadata['sizes'] as $size => $info) {
65
+ $filename = $info['file'];
66
+
67
+ if (!isset($unique_sizes[$filename])) {
68
+ $this->filenames[$size] = "$path_prefix$filename";
69
+ $this->urls[$size] = "$url_prefix$filename";
70
+ $unique_sizes[$filename] = true;
71
+ }
72
  }
73
  }
74
  }
78
  }
79
 
80
  public function add_response($response, $size=self::ORIGINAL) {
81
+ $data = array(
82
  'input' => array('size' => $response['input']['size']),
83
  'output' => array('size' => $response['output']['size']),
84
+ 'end' => time()
85
+ );
86
+ $this->values[$size] = array_merge($this->values[$size], $data);
87
+ }
88
+
89
+ public function add_request($size=self::ORIGINAL) {
90
+ $this->values[$size] = array(
91
+ 'start' => time()
92
  );
93
  }
94
 
122
  && file_exists($filename) && filesize($filename) == $this->values[$size]['output']['size'];
123
  }
124
 
125
+ public function is_compressing($size=self::ORIGINAL) {
126
+ $meta = $this->values[$size];
127
+ return isset($meta) && isset($meta['start']) && !isset($meta['output']);
128
+ }
129
+
130
  public function get_sizes() {
131
  return array_keys($this->filenames);
132
  }
135
  return array_filter(array_keys($this->values), array($this, 'is_compressed'));
136
  }
137
 
138
+ public function get_uncompressed_sizes($active_tinify_sizes) {
139
+ $sizes = array_intersect($this->get_sizes(), $active_tinify_sizes);
140
  return array_diff($sizes, $this->get_success_sizes());
141
  }
142
 
143
+ public function get_in_progress_sizes() {
144
+ return array_filter(array_keys($this->values), array($this, 'is_compressing'));
145
+ }
146
+
147
  public function get_latest_error() {
148
  $last_time = null;
149
  $message = null;
src/class-tiny-plugin.php CHANGED
@@ -30,6 +30,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
30
 
31
  public function __construct() {
32
  parent::__construct();
 
33
  $this->settings = new Tiny_Settings();
34
  if (is_admin()) {
35
  add_action('admin_menu', $this->get_method('admin_menu'));
@@ -100,14 +101,20 @@ class Tiny_Plugin extends Tiny_WP_Base {
100
  $failed = 0;
101
 
102
  $compressor = $this->settings->get_compressor();
103
- $sizes = $this->settings->get_tinify_sizes();
104
- foreach ($tiny_metadata->get_missing_sizes($sizes) as $size) {
 
 
105
  try {
106
- $response = $compressor->compress_file($tiny_metadata->get_filename($size));
107
- $tiny_metadata->add_response($response, $size);
 
 
 
 
108
  $success++;
109
  } catch (Tiny_Exception $e) {
110
- $tiny_metadata->add_exception($e, $size);
111
  $failed++;
112
  }
113
  }
@@ -185,9 +192,14 @@ class Tiny_Plugin extends Tiny_WP_Base {
185
  }
186
 
187
  private function render_compress_details($tiny_metadata) {
188
- $missing = $tiny_metadata->get_missing_sizes($this->settings->get_tinify_sizes());
189
  $success = count($tiny_metadata->get_success_sizes());
190
  $total = count($missing) + $success;
 
 
 
 
 
191
 
192
  if (count($missing) > 0) {
193
  printf(self::translate_escape('Compressed %d out of %d sizes'), $success, $total);
@@ -198,6 +210,8 @@ class Tiny_Plugin extends Tiny_WP_Base {
198
  echo '<button type="button" class="tiny-compress" data-id="' . $tiny_metadata->get_id() . '">' .
199
  self::translate_escape('Compress') . '</button>';
200
  echo '<div class="spinner hidden"></div>';
 
 
201
  } else {
202
  printf(self::translate_escape('Compressed %d out of %d sizes'), $success, $total);
203
  $savings = $tiny_metadata->get_savings();
30
 
31
  public function __construct() {
32
  parent::__construct();
33
+
34
  $this->settings = new Tiny_Settings();
35
  if (is_admin()) {
36
  add_action('admin_menu', $this->get_method('admin_menu'));
101
  $failed = 0;
102
 
103
  $compressor = $this->settings->get_compressor();
104
+ $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
105
+ $uncompressed_sizes = $tiny_metadata->get_uncompressed_sizes($active_tinify_sizes);
106
+
107
+ foreach ($uncompressed_sizes as $uncompressed_size) {
108
  try {
109
+ $tiny_metadata->add_request($uncompressed_size);
110
+ $tiny_metadata->update();
111
+ $response = $compressor->compress_file($tiny_metadata->get_filename($uncompressed_size));
112
+ $responses[$uncompressed_size] = $response;
113
+
114
+ $tiny_metadata->add_response($response, $uncompressed_size);
115
  $success++;
116
  } catch (Tiny_Exception $e) {
117
+ $tiny_metadata->add_exception($e, $uncompressed_size);
118
  $failed++;
119
  }
120
  }
192
  }
193
 
194
  private function render_compress_details($tiny_metadata) {
195
+ $missing = $tiny_metadata->get_uncompressed_sizes($this->settings->get_active_tinify_sizes());
196
  $success = count($tiny_metadata->get_success_sizes());
197
  $total = count($missing) + $success;
198
+ $progress = count($tiny_metadata->get_in_progress_sizes());
199
+
200
+ $duplicates = count($this->settings->get_active_tinify_sizes()) - $total;
201
+ $success += $duplicates;
202
+ $total += $duplicates;
203
 
204
  if (count($missing) > 0) {
205
  printf(self::translate_escape('Compressed %d out of %d sizes'), $success, $total);
210
  echo '<button type="button" class="tiny-compress" data-id="' . $tiny_metadata->get_id() . '">' .
211
  self::translate_escape('Compress') . '</button>';
212
  echo '<div class="spinner hidden"></div>';
213
+ } elseif ($progress > 0) {
214
+ printf(self::translate_escape('Compressing %d sizes...'), count($this->settings->get_active_tinify_sizes()));
215
  } else {
216
  printf(self::translate_escape('Compressed %d out of %d sizes'), $success, $total);
217
  $savings = $tiny_metadata->get_savings();
src/class-tiny-settings.php CHANGED
@@ -124,7 +124,7 @@ class Tiny_Settings extends Tiny_WP_Base {
124
  continue;
125
  }
126
  list($width, $height) = self::get_intermediate_size($size);
127
- if ($width && $height) {
128
  $this->sizes[$size] = array(
129
  'width' => $width, 'height' => $height,
130
  'tinify' => !is_array($setting) || (isset($setting[$size]) && $setting[$size] === 'on'),
@@ -134,7 +134,7 @@ class Tiny_Settings extends Tiny_WP_Base {
134
  return $this->sizes;
135
  }
136
 
137
- public function get_tinify_sizes() {
138
  if (is_array($this->tinify_sizes)) {
139
  return $this->tinify_sizes;
140
  }
124
  continue;
125
  }
126
  list($width, $height) = self::get_intermediate_size($size);
127
+ if ($width || $height) {
128
  $this->sizes[$size] = array(
129
  'width' => $width, 'height' => $height,
130
  'tinify' => !is_array($setting) || (isset($setting[$size]) && $setting[$size] === 'on'),
134
  return $this->sizes;
135
  }
136
 
137
+ public function get_active_tinify_sizes() {
138
  if (is_array($this->tinify_sizes)) {
139
  return $this->tinify_sizes;
140
  }
src/languages/tiny-compress-images-nl_NL.mo CHANGED
Binary file
src/languages/tiny-compress-images-nl_NL.po CHANGED
@@ -1,9 +1,6 @@
1
  msgid "PNG and JPEG compression"
2
  msgstr "PNG- en JPEG-compressie"
3
 
4
- msgid "Multisite PNG and JPEG compression"
5
- msgstr "Multisite PNG- en JPEG-compressie"
6
-
7
  msgid "Visit %s to get an API key"
8
  msgstr "Bezoek de %s om een API-sleutel te krijgen"
9
 
@@ -16,9 +13,6 @@ msgstr "TinyPNG Developer pagina"
16
  msgid "TinyPNG API key"
17
  msgstr "TinyPNG API-sleutel"
18
 
19
- msgid "Multisite API key"
20
- msgstr "Multisite API-sleutel"
21
-
22
  msgid "File compression"
23
  msgstr "Bestandscompressie"
24
 
@@ -43,6 +37,9 @@ msgstr "Comprimeer Afbeeldingen"
43
  msgid "Compressed %d out of %d sizes"
44
  msgstr "%d van de %d afmetingen zijn gecomprimeerd"
45
 
 
 
 
46
  msgid "Total size"
47
  msgstr "Totale grootte"
48
 
@@ -88,12 +85,9 @@ msgstr "Kon geen outputlocatie vinden"
88
  msgid "Could not download output"
89
  msgstr "Kon output niet downloaden"
90
 
91
- msgid "File does not exists"
92
  msgstr "Bestand bestaat niet"
93
 
94
- msgid "Could not decode JSON"
95
- msgstr "Kon JSON niet decoderen"
96
-
97
  msgid "Could not compress, enable cURL for detailed error"
98
  msgstr "Kon niet comprimeren, schakel cURL in voor een preciezere foutmelding"
99
 
1
  msgid "PNG and JPEG compression"
2
  msgstr "PNG- en JPEG-compressie"
3
 
 
 
 
4
  msgid "Visit %s to get an API key"
5
  msgstr "Bezoek de %s om een API-sleutel te krijgen"
6
 
13
  msgid "TinyPNG API key"
14
  msgstr "TinyPNG API-sleutel"
15
 
 
 
 
16
  msgid "File compression"
17
  msgstr "Bestandscompressie"
18
 
37
  msgid "Compressed %d out of %d sizes"
38
  msgstr "%d van de %d afmetingen zijn gecomprimeerd"
39
 
40
+ msgid "Compressing %d sizes..."
41
+ msgstr "%d afmetingen worden gecomprimeerd..."
42
+
43
  msgid "Total size"
44
  msgstr "Totale grootte"
45
 
85
  msgid "Could not download output"
86
  msgstr "Kon output niet downloaden"
87
 
88
+ msgid "File does not exist"
89
  msgstr "Bestand bestaat niet"
90
 
 
 
 
91
  msgid "Could not compress, enable cURL for detailed error"
92
  msgstr "Kon niet comprimeren, schakel cURL in voor een preciezere foutmelding"
93
 
src/languages/tiny-compress-images-ru_RU.mo CHANGED
Binary file
src/languages/tiny-compress-images-ru_RU.po CHANGED
@@ -16,9 +16,6 @@ msgstr ""
16
  msgid "PNG and JPEG compression"
17
  msgstr "Сжатие PNG и JPEG"
18
 
19
- msgid "Multisite PNG and JPEG compression"
20
- msgstr "PNG и JPEG сжатие для Multisite"
21
-
22
  msgid "Visit %s to get an API key"
23
  msgstr "Посетите %s, чтобы получить API ключ"
24
 
@@ -31,9 +28,6 @@ msgstr "раздел TinyPNG для разработчиков"
31
  msgid "TinyPNG API key"
32
  msgstr "TinyPNG API ключ"
33
 
34
- msgid "Multisite API key"
35
- msgstr "Multisite API ключ"
36
-
37
  msgid "File compression"
38
  msgstr "Сжатие файлов"
39
 
@@ -103,12 +97,9 @@ msgstr "Не могу найти url результата"
103
  msgid "Could not download output"
104
  msgstr "Не могу загрузить результат"
105
 
106
- msgid "File does not exists"
107
  msgstr "Файл не существует или не найден плагином"
108
 
109
- msgid "Could not decode JSON"
110
- msgstr "Не могу раскодировать JSON"
111
-
112
  msgid "Could not compress, enable cURL for detailed error"
113
  msgstr "Не могу сжать. Подключите cURL для деталей"
114
 
16
  msgid "PNG and JPEG compression"
17
  msgstr "Сжатие PNG и JPEG"
18
 
 
 
 
19
  msgid "Visit %s to get an API key"
20
  msgstr "Посетите %s, чтобы получить API ключ"
21
 
28
  msgid "TinyPNG API key"
29
  msgstr "TinyPNG API ключ"
30
 
 
 
 
31
  msgid "File compression"
32
  msgstr "Сжатие файлов"
33
 
97
  msgid "Could not download output"
98
  msgstr "Не могу загрузить результат"
99
 
100
+ msgid "File does not exist"
101
  msgstr "Файл не существует или не найден плагином"
102
 
 
 
 
103
  msgid "Could not compress, enable cURL for detailed error"
104
  msgstr "Не могу сжать. Подключите cURL для деталей"
105
 
src/languages/tiny-compress-images-zh_TW.mo ADDED
Binary file
src/languages/tiny-compress-images-zh_TW.po ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: \n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.4\n"
11
+ "Last-Translator: Pseric <pserics@gmail.com>\n"
12
+ "Plural-Forms: nplurals=1; plural=0;\n"
13
+ "Language: zh_TW\n"
14
+
15
+ msgid "PNG and JPEG compression"
16
+ msgstr "PNG 和 JPEG 壓縮"
17
+
18
+ msgid "Visit %s to get an API key"
19
+ msgstr "訪問 %s 取得一個 API 金鑰"
20
+
21
+ msgid "Visit %s to view your usage or upgrade your account"
22
+ msgstr "訪問 %s 檢視你的使用量或升級你的帳號"
23
+
24
+ msgid "TinyPNG Developer section"
25
+ msgstr "TinyPNG 開發者功能"
26
+
27
+ msgid "TinyPNG API key"
28
+ msgstr "TinyPNG API 金鑰"
29
+
30
+ msgid "File compression"
31
+ msgstr "檔案壓縮"
32
+
33
+ msgid "original"
34
+ msgstr "原始大小"
35
+
36
+ msgid "You can choose to compress different image sizes created by WordPress here"
37
+ msgstr "你可以在這裡選擇要壓縮的圖片大小,由 WordPress 建立"
38
+
39
+ msgid "Remember each additional image size will affect your TinyPNG monthly usage"
40
+ msgstr "請記住,每個額外圖片尺寸都會影響你的 TinyPNG 每月使用量"
41
+
42
+ msgid "Compression"
43
+ msgstr "壓縮"
44
+
45
+ msgid "Compress"
46
+ msgstr "壓縮"
47
+
48
+ msgid "Compress Images"
49
+ msgstr "壓縮圖片"
50
+
51
+ msgid "Compressed %d out of %d sizes"
52
+ msgstr "已壓縮 %d/%d 個尺寸"
53
+
54
+ msgid "Compressing %d sizes..."
55
+ msgstr "壓縮 %d 個尺寸..."
56
+
57
+ msgid "Total size"
58
+ msgstr "總共大小"
59
+
60
+ msgid "Compressed size"
61
+ msgstr "已壓縮尺寸"
62
+
63
+ msgid "Latest error"
64
+ msgstr "最近錯誤"
65
+
66
+ msgid "Error"
67
+ msgstr "錯誤"
68
+
69
+ msgid "Internal error"
70
+ msgstr "內部錯誤"
71
+
72
+ msgid "Credentials are invalid"
73
+ msgstr "憑證無效"
74
+
75
+ msgid "Your monthly limit has been exceeded"
76
+ msgstr "你的每月限額已經超過"
77
+
78
+ msgid "File is empty"
79
+ msgstr "檔案是空的"
80
+
81
+ msgid "Does not appear to be a PNG or JPEG file"
82
+ msgstr "似乎不是一個 PNG 或 JPEG 檔案"
83
+
84
+ msgid "CMYK color space is not supported"
85
+ msgstr "不支援 CMYK 色彩空間"
86
+
87
+ msgid "Image appears corrupt"
88
+ msgstr "圖片似乎已經損壞"
89
+
90
+ msgid "Compression failed"
91
+ msgstr "壓縮失敗"
92
+
93
+ msgid "No HTTP client is available (cURL or fopen)"
94
+ msgstr "沒有 HTTP 客戶端可用(cURL 或 fopen)"
95
+
96
+ msgid "Could not find output url"
97
+ msgstr "找不到輸出網址"
98
+
99
+ msgid "Could not download output"
100
+ msgstr "無法下載輸出"
101
+
102
+ msgid "File does not exist"
103
+ msgstr "檔案不存在"
104
+
105
+ msgid "Could not compress, enable cURL for detailed error"
106
+ msgstr "無法壓縮,啟用 cURL 取得詳細錯誤資訊"
107
+
108
+ msgid "You don't have permission to work with uploaded files"
109
+ msgstr "你沒有權限來處理上傳的檔案"
110
+
111
+ msgid "Not a valid media file"
112
+ msgstr "不是一個有效的媒體檔案"
113
+
114
+ msgid "Could not find metadata of media file"
115
+ msgstr "找不到媒體檔案的 metadata"
116
+
117
+ msgid "The API key has been configured in %s"
118
+ msgstr "這個 API 金鑰已經設定在 %s"
119
+
120
+ msgid "Connection status"
121
+ msgstr "連線狀態"
122
+
123
+ msgid "Dismiss"
124
+ msgstr "拒絕"
125
+
126
+ msgid "TinyPNG API account"
127
+ msgstr "TinyPNG API 帳號"
128
+
129
+ msgid "API connection successful"
130
+ msgstr "API 連線成功"
131
+
132
+ msgid "API connection unsuccessful"
133
+ msgstr "API 連線不成功"
134
+
135
+ msgid "API status could not be checked, enable cURL for more information"
136
+ msgstr "無法檢查 API 狀態,啟用 cURL 取得更多資訊"
137
+
138
+ msgid "You have made %s compressions this month"
139
+ msgstr "本月你已經壓縮 %s 張圖片"
140
+
141
+ msgid "You have reached your limit of %s compressions this month"
142
+ msgstr "本月你已經到達你的壓縮限制 %s 張圖片"
143
+
144
+ msgid "If you need to compress more images you can change your %s"
145
+ msgstr "如果你需要壓縮更多圖片,你可以變更你的 %s"
146
+
147
+ msgid "Upgrade your %s if you like to compress more images"
148
+ msgstr "如果你想壓縮更多圖片,升級你的 %s"
149
+
150
+ msgid "Please fill in an API key to start compressing images"
151
+ msgstr "請填入一個 API 金鑰來開始壓縮圖片"
152
+
153
+ msgid "Compress All Images"
154
+ msgstr "壓縮所有圖片"
155
+
156
+ msgid "Compress JPEG & PNG Images"
157
+ msgstr "壓縮 JPEG & PNG 圖片"
158
+
159
+ msgid "All images are processed"
160
+ msgstr "所有圖片皆處理完成"
161
+
162
+ msgid "Compressions this month"
163
+ msgstr "本月壓縮"
164
+
165
+ msgid "Processing"
166
+ msgstr "處理中"
167
+
168
+ msgid "Waiting"
169
+ msgstr "等待中"
170
+
171
+ msgid "Compressing"
172
+ msgstr "壓縮中"
173
+
174
+ msgid "compressions"
175
+ msgstr "壓縮"
176
+
177
+ msgid "out of"
178
+ msgstr "以外"
179
+
180
+ msgid "Use this tool to compress all images in your media library"
181
+ msgstr "使用這個工具來壓縮你媒體庫的所有圖片"
182
+
183
+ msgid "Only images that have not been compressed will be compressed"
184
+ msgstr "只有沒被壓縮過的圖片才會壓縮"
185
+
186
+ msgid "We have found %d images in your media library"
187
+ msgstr "我們在你的媒體庫找到 %d 張圖片"
188
+
189
+ msgid "To begin, just press the button below"
190
+ msgstr "如要開始,只要點選下方案扭"
191
+
192
+ msgid "Please be patient while the images are being compressed"
193
+ msgstr "相片壓縮時請耐心等待"
194
+
195
+ msgid "This can take a while if you have many images"
196
+ msgstr "如果你有許多圖片,這可能需要一段時間"
197
+
198
+ msgid "Do not navigate away from this page because it will stop the process"
199
+ msgstr "請不要離開此頁面,因為它會停止壓縮程序"
200
+
201
+ msgid "You will be notified via this page when the processing is done"
202
+ msgstr "當處理完成後,你將透過此頁面取得通知"
test/helpers/setup.php CHANGED
@@ -103,8 +103,12 @@ function setup_wordpress_site($driver) {
103
  }
104
  $driver->findElement(WebDriverBy::name('weblog_title'))->sendKeys('Wordpress test');
105
  $driver->findElement(WebDriverBy::name('user_name'))->clear()->sendKeys('admin');
106
- $driver->findElement(WebDriverBy::name('admin_password'))->sendKeys('admin');
107
- $driver->findElement(WebDriverBy::name('admin_password2'))->sendKeys('admin');
 
 
 
 
108
  $driver->findElement(WebDriverBy::name('admin_email'))->sendKeys('developers@voormedia.com');
109
  $driver->findElement(WebDriverBy::tagName('form'))->submit();
110
  $h1s = $driver->findElements(WebDriverBy::tagName('h1'));
@@ -118,13 +122,16 @@ function setup_wordpress_site($driver) {
118
  }
119
 
120
  function login($driver) {
 
121
  $driver->get(wordpress('/wp-login.php'));
122
  $driver->findElement(WebDriverBy::tagName('body'))->click();
123
  $driver->findElement(WebDriverBy::name('log'))->clear()->click()->sendKeys('admin');
124
  $driver->findElement(WebDriverBy::name('pwd'))->clear()->click()->sendKeys('admin');
125
  $driver->findElement(WebDriverBy::tagName('form'))->submit();
126
- if ($driver->findElement(WebDriverBy::tagName('h2'))->getText() == 'Dashboard') {
127
- print "Successfully logged into WordPress.\n";
 
 
128
  } else {
129
  var_dump($driver->getPageSource());
130
  throw new UnexpectedValueException('Login failed.');
@@ -157,7 +164,6 @@ function reset_webservice() {
157
  curl_setopt_array($request, array(
158
  CURLOPT_URL => 'http://' . getenv('HOST_IP') .':8080/reset',
159
  ));
160
-
161
  $response = curl_exec($request);
162
  curl_close($request);
163
  }
103
  }
104
  $driver->findElement(WebDriverBy::name('weblog_title'))->sendKeys('Wordpress test');
105
  $driver->findElement(WebDriverBy::name('user_name'))->clear()->sendKeys('admin');
106
+ if (wordpress_version() > 42) {
107
+ $driver->findElement(WebDriverBy::id('pass1-text'))->clear()->sendKeys('a')->sendKeys('dmin');
108
+ } else {
109
+ $driver->findElement(WebDriverBy::name('admin_password'))->sendKeys('admin');
110
+ $driver->findElement(WebDriverBy::name('admin_password2'))->sendKeys('admin');
111
+ }
112
  $driver->findElement(WebDriverBy::name('admin_email'))->sendKeys('developers@voormedia.com');
113
  $driver->findElement(WebDriverBy::tagName('form'))->submit();
114
  $h1s = $driver->findElements(WebDriverBy::tagName('h1'));
122
  }
123
 
124
  function login($driver) {
125
+ print "Logging in to Wordpress... ";
126
  $driver->get(wordpress('/wp-login.php'));
127
  $driver->findElement(WebDriverBy::tagName('body'))->click();
128
  $driver->findElement(WebDriverBy::name('log'))->clear()->click()->sendKeys('admin');
129
  $driver->findElement(WebDriverBy::name('pwd'))->clear()->click()->sendKeys('admin');
130
  $driver->findElement(WebDriverBy::tagName('form'))->submit();
131
+
132
+ $dashboardHeading = $driver->findElement(WebDriverBy::xpath("//html/body//div[@class='wrap']/*[self::h1 or self::h2]"));
133
+ if ($dashboardHeading->getText() == 'Dashboard') {
134
+ print "success!\n";
135
  } else {
136
  var_dump($driver->getPageSource());
137
  throw new UnexpectedValueException('Login failed.');
164
  curl_setopt_array($request, array(
165
  CURLOPT_URL => 'http://' . getenv('HOST_IP') .':8080/reset',
166
  ));
 
167
  $response = curl_exec($request);
168
  curl_close($request);
169
  }
test/integration/BulkCompressIntegrationTest.php CHANGED
@@ -35,7 +35,7 @@ class BulkCompressIntegrationTest extends IntegrationTestCase {
35
  $this->enable_compression_sizes(array('thumbnail', 'medium', 'large'));
36
  }
37
 
38
- public function testBulkCompressShouldFromMediaShouldOnlyCompressSelected() {
39
  $this->prepare(1, 2);
40
 
41
  self::$driver->get(wordpress('/wp-admin/upload.php?orderby=title&order=asc'));
35
  $this->enable_compression_sizes(array('thumbnail', 'medium', 'large'));
36
  }
37
 
38
+ public function testBulkCompressFromMediaShouldOnlyCompressSelected() {
39
  $this->prepare(1, 2);
40
 
41
  self::$driver->get(wordpress('/wp-admin/upload.php?orderby=title&order=asc'));
test/integration/CompressIntegrationTest.php CHANGED
@@ -67,4 +67,17 @@ class CompressIntegrationTest extends IntegrationTestCase {
67
  self::$driver->get(wordpress('/wp-admin/options-media.php'));
68
  $this->assertEquals(0, count(self::$driver->findElements(WebDriverBy::cssSelector('div.error p'))));
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
67
  self::$driver->get(wordpress('/wp-admin/options-media.php'));
68
  $this->assertEquals(0, count(self::$driver->findElements(WebDriverBy::cssSelector('div.error p'))));
69
  }
70
+
71
+ public function testIncorrectJsonButton() {
72
+ $this->enable_compression_sizes(array());
73
+ $this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
74
+ $this->enable_compression_sizes(array('medium', 'large'));
75
+
76
+ $this->set_api_key('JSON1234');
77
+ self::$driver->get(wordpress('/wp-admin/upload.php'));
78
+
79
+ self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images button'))->click();
80
+ self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(
81
+ WebDriverBy::cssSelector('td.tiny-compress-images'), 'JSON: Syntax error [4]'));
82
+ }
83
  }
test/integration/SettingsIntegrationTest.php CHANGED
@@ -89,6 +89,7 @@ class SettingsIntegrationTest extends IntegrationTestCase {
89
  public function testStatusPresenceOK() {
90
  reset_webservice();
91
  $this->set_api_key('PNG123');
 
92
  $elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-status'))->findElements(WebDriverBy::tagName('p'));
93
  $statuses = array_map('innerText', $elements);
94
  $this->assertContains('API connection successful', $statuses);
@@ -97,6 +98,7 @@ class SettingsIntegrationTest extends IntegrationTestCase {
97
 
98
  public function testStatusPresenseFail() {
99
  $this->set_api_key('INVALID123');
 
100
  $elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-status'))->findElements(WebDriverBy::tagName('p'));
101
  $statuses = array_map('innerText', $elements);
102
  $this->assertContains('API connection unsuccessful', $statuses);
89
  public function testStatusPresenceOK() {
90
  reset_webservice();
91
  $this->set_api_key('PNG123');
92
+ self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#tiny-compress-status p')));
93
  $elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-status'))->findElements(WebDriverBy::tagName('p'));
94
  $statuses = array_map('innerText', $elements);
95
  $this->assertContains('API connection successful', $statuses);
98
 
99
  public function testStatusPresenseFail() {
100
  $this->set_api_key('INVALID123');
101
+ self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#tiny-compress-status p')));
102
  $elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-status'))->findElements(WebDriverBy::tagName('p'));
103
  $statuses = array_map('innerText', $elements);
104
  $this->assertContains('API connection unsuccessful', $statuses);
test/mock-tinypng-webservice/shrink.php CHANGED
@@ -94,6 +94,16 @@ function mock_limit_reached_response() {
94
  return json_encode($response);
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
97
  $request_headers = apache_request_headers();
98
  $basic_auth = base64_decode(str_replace('Basic ', '', $request_headers['Authorization']));
99
  $api_key_elements = explode(':', $basic_auth);
@@ -113,6 +123,12 @@ if ($api_key == 'PNG123') {
113
  } else {
114
  echo mock_jpg_response();
115
  }
 
 
 
 
 
 
116
  } else if ($api_key == 'LIMIT123') {
117
  echo mock_limit_reached_response();
118
  } else {
94
  return json_encode($response);
95
  }
96
 
97
+ function mock_invalid_json_response() {
98
+ global $session;
99
+
100
+ $session['Compression-Count'] += 1;
101
+ header('HTTP/1.1 201 Created');
102
+ header("Location: http://webservice/output/example.png");
103
+ header("Compression-Count: {$session['Compression-Count']}");
104
+ return '{invalid: json}';
105
+ }
106
+
107
  $request_headers = apache_request_headers();
108
  $basic_auth = base64_decode(str_replace('Basic ', '', $request_headers['Authorization']));
109
  $api_key_elements = explode(':', $basic_auth);
123
  } else {
124
  echo mock_jpg_response();
125
  }
126
+ } else if ($api_key == 'JSON1234') {
127
+ if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
128
+ echo mock_empty_response();
129
+ } else {
130
+ echo mock_invald_json_response();
131
+ }
132
  } else if ($api_key == 'LIMIT123') {
133
  echo mock_limit_reached_response();
134
  } else {
test/unit/TinyMetadataTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(dirname(__FILE__) . "/TinyTestCase.php");
4
+
5
+ class Tiny_Metadata_Test extends TinyTestCase {
6
+ public function setUp() {
7
+ parent::setUp();
8
+
9
+ $this->wp->addOption("tinypng_api_key", "test123");
10
+ $this->wp->addOption("tinypng_sizes[0]", "on");
11
+ $this->wp->addOption("tinypng_sizes[custom-size]", "on");
12
+ $this->wp->addOption("tinypng_sizes[custom-size-2]", "on");
13
+ $this->wp->addImageSize('custom-size', array('width' => 150, 'height' => 150));
14
+ $this->wp->addImageSize('custom-size-2', array('width' => 150, 'height' => 150));
15
+ $this->wp->createImages();
16
+
17
+ $wp_metadata = array();
18
+ $wp_metadata['file'] = "2015/09/panda.jpg";
19
+ $wp_metadata['width'] = 1080;
20
+ $wp_metadata['height'] = 720;
21
+ $wp_metadata['sizes'] = array();
22
+
23
+ $wp_metadata['sizes']['custom-size'] = array();
24
+ $wp_metadata['sizes']['custom-size']['file'] = "panda-150x150.jpg";
25
+ $wp_metadata['sizes']['custom-size']['width'] = 150;
26
+ $wp_metadata['sizes']['custom-size']['height'] = 150;
27
+
28
+ $wp_metadata['sizes']['custom-size-2'] = array();
29
+ $wp_metadata['sizes']['custom-size-2']['file'] = "panda-150x150.jpg";
30
+ $wp_metadata['sizes']['custom-size-2']['width'] = 150;
31
+ $wp_metadata['sizes']['custom-size-2']['height'] = 150;
32
+
33
+ $this->subject = new Tiny_Metadata(150, $wp_metadata);
34
+ }
35
+
36
+ public function testGetUncompressedSizesShouldReturnOnlyUniqueSizes() {
37
+ $tinify_sizes = array(Tiny_Metadata::ORIGINAL, "custom-size", "custom-size-2");
38
+ $uncompressed_sizes = array(Tiny_Metadata::ORIGINAL, "custom-size");
39
+ $this->assertEquals($uncompressed_sizes, $this->subject->get_uncompressed_sizes($tinify_sizes));
40
+ }
41
+ }
test/unit/TinyPluginTest.php CHANGED
@@ -72,7 +72,9 @@ class Tiny_Plugin_Test extends TinyTestCase {
72
 
73
  $testmeta = $this->wp->getTestMetadata();
74
  $meta = new Tiny_Metadata(1, $testmeta);
 
75
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test.png'));
 
76
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-large.png'), 'large');
77
  $meta->update();
78
 
@@ -87,8 +89,11 @@ class Tiny_Plugin_Test extends TinyTestCase {
87
 
88
  $testmeta = $this->wp->getTestMetadata();
89
  $meta = new Tiny_Metadata(1, $testmeta);
 
90
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test.png'));
 
91
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-large.png'), 'large');
 
92
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-post-thumbnail.png'), 'post-thumbnail');
93
  $meta->update();
94
 
@@ -110,8 +115,9 @@ class Tiny_Plugin_Test extends TinyTestCase {
110
 
111
  $metadata = $this->wp->getMetadata(1, 'tiny_compress_images', true);
112
  foreach ($metadata as $key => $values) {
113
- $this->assertEquals(time(), $values['timestamp'], 2);
114
- unset($metadata[$key]['timestamp']);
 
115
  }
116
  $this->assertEquals(array(
117
  0 => array('input' => array('size' => 12345), 'output' => array('size' => 10000)),
@@ -178,6 +184,6 @@ class Tiny_Plugin_Test extends TinyTestCase {
178
  $testmeta['sizes'] = 0;
179
 
180
  $this->subject->compress_attachment($testmeta, 1);
181
- $this->assertEquals(1, count($this->wp->getCalls('update_post_meta')));
182
  }
183
  }
72
 
73
  $testmeta = $this->wp->getTestMetadata();
74
  $meta = new Tiny_Metadata(1, $testmeta);
75
+ $meta->add_request();
76
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test.png'));
77
+ $meta->add_request('large');
78
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-large.png'), 'large');
79
  $meta->update();
80
 
89
 
90
  $testmeta = $this->wp->getTestMetadata();
91
  $meta = new Tiny_Metadata(1, $testmeta);
92
+ $meta->add_request();
93
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test.png'));
94
+ $meta->add_request('large');
95
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-large.png'), 'large');
96
+ $meta->add_request('post-thumbnail');
97
  $meta->add_response(self::successCompress('vfs://root/wp-content/uploads/14/01/test-post-thumbnail.png'), 'post-thumbnail');
98
  $meta->update();
99
 
115
 
116
  $metadata = $this->wp->getMetadata(1, 'tiny_compress_images', true);
117
  foreach ($metadata as $key => $values) {
118
+ $this->assertBetween(-1, +1, $values['end'] - time());
119
+ unset($metadata[$key]['end']);
120
+ unset($metadata[$key]['start']);
121
  }
122
  $this->assertEquals(array(
123
  0 => array('input' => array('size' => 12345), 'output' => array('size' => 10000)),
184
  $testmeta['sizes'] = 0;
185
 
186
  $this->subject->compress_attachment($testmeta, 1);
187
+ $this->assertEquals(2, count($this->wp->getCalls('update_post_meta')));
188
  }
189
  }
test/unit/TinySettingsTest.php CHANGED
@@ -32,20 +32,6 @@ class Tiny_Settings_Test extends TinyTestCase {
32
  ), $this->wp->getCalls('add_settings_field'));
33
  }
34
 
35
- public function testShouldRetrieveOnlyAvailableSizes() {
36
- $this->wp->addImageSize('post-thumbnail', array('width' => 825, 'height' => 510));
37
- $this->wp->addImageSize('wrong', null);
38
- $this->wp->addImageSize('missing', array('width' => 825));
39
-
40
- $this->assertEquals(array(
41
- 0 => array('width' => null, 'height' => null, 'tinify' => true),
42
- 'thumbnail' => array('width' => 150, 'height' => 150, 'tinify' => true),
43
- 'medium' => array('width' => 300, 'height' => 300, 'tinify' => true),
44
- 'large' => array('width' => 1024, 'height' => 1024, 'tinify' => true),
45
- 'post-thumbnail' => array('width' => 825, 'height' => 510, 'tinify' => true)
46
- ), $this->subject->get_sizes());
47
- }
48
-
49
  public function testShouldRetrieveSizesWithSettings() {
50
  $this->wp->addOption("tinypng_sizes[0]", "on");
51
  $this->wp->addOption("tinypng_sizes[medium]", "on");
@@ -86,4 +72,31 @@ class Tiny_Settings_Test extends TinyTestCase {
86
  'large' => array('width' => 1024, 'height' => 1024, 'tinify' => true),
87
  ), $this->subject->get_sizes());
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
32
  ), $this->wp->getCalls('add_settings_field'));
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  public function testShouldRetrieveSizesWithSettings() {
36
  $this->wp->addOption("tinypng_sizes[0]", "on");
37
  $this->wp->addOption("tinypng_sizes[medium]", "on");
72
  'large' => array('width' => 1024, 'height' => 1024, 'tinify' => true),
73
  ), $this->subject->get_sizes());
74
  }
75
+
76
+ public function testShouldShowAdditionalSize() {
77
+ $this->wp->addImageSize('additional_size_1', array('width' => 666, 'height' => 333));
78
+ $this->subject->get_sizes();
79
+ $sizes = $this->subject->get_sizes();
80
+ $this->assertEquals(
81
+ array('width' => 666, 'height' => 333, 'tinify' => true),
82
+ $sizes["additional_size_1"]);
83
+ }
84
+
85
+ public function testShouldShowAdditionalSizeWithoutHeight() {
86
+ $this->wp->addImageSize('additional_size_no_height', array('width' => 777));
87
+ $this->subject->get_sizes();
88
+ $sizes = $this->subject->get_sizes();
89
+ $this->assertEquals(
90
+ array('width' => 777, 'height' => 0, 'tinify' => true),
91
+ $sizes["additional_size_no_height"]);
92
+ }
93
+
94
+ public function testShouldShowAdditionalSizeWithoutWidth() {
95
+ $this->wp->addImageSize('additional_size_no_width', array('height' => 888));
96
+ $this->subject->get_sizes();
97
+ $sizes = $this->subject->get_sizes();
98
+ $this->assertEquals(
99
+ array('width' => 0, 'height' => 888, 'tinify' => true),
100
+ $sizes["additional_size_no_width"]);
101
+ }
102
  }
test/unit/TinyTestCase.php CHANGED
@@ -27,4 +27,9 @@ abstract class TinyTestCase extends PHPUnit_Framework_TestCase {
27
 
28
  protected function tearDown() {
29
  }
 
 
 
 
 
30
  }
27
 
28
  protected function tearDown() {
29
  }
30
+
31
+ protected function assertBetween($lower_bound, $upper_bound, $actual, $message='') {
32
+ $this->assertGreaterThanOrEqual($lower_bound, $actual, $message);
33
+ $this->assertLessThanOrEqual($upper_bound, $actual, $message);
34
+ }
35
  }
tiny-compress-images.php CHANGED
@@ -2,13 +2,12 @@
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: 1.3.0
6
  * Author: TinyPNG
7
  * Author URI: https://tinypng.com
8
  * License: GPLv2 or later
9
  */
10
 
11
-
12
  require (dirname(__FILE__) . '/src/config/tiny-config.php');
13
  require (dirname(__FILE__) . '/src/class-tiny-php.php');
14
  require (dirname(__FILE__) . '/src/class-tiny-wp-base.php');
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: 1.3.2
6
  * Author: TinyPNG
7
  * Author URI: https://tinypng.com
8
  * License: GPLv2 or later
9
  */
10
 
 
11
  require (dirname(__FILE__) . '/src/config/tiny-config.php');
12
  require (dirname(__FILE__) . '/src/class-tiny-php.php');
13
  require (dirname(__FILE__) . '/src/class-tiny-wp-base.php');