Version Description
- Option to preserve gps location and original creation date and time in your original JPEG images.
- Option to preserve coyright information in your original PNG images.
- Improved handling of unsupported image files (e.g. GIF)
Download this release
Release Info
Developer | TinyPNG |
Plugin | Compress JPEG & PNG images |
Version | 1.7.1 |
Comparing to | |
See all releases |
Code changes from version 1.7.0 to 1.7.1
- README.md +2 -2
- readme.txt +44 -39
- src/class-tiny-compress-curl.php +3 -2
- src/class-tiny-compress-fopen.php +15 -11
- src/class-tiny-compress.php +20 -6
- src/class-tiny-exception.php +1 -1
- src/class-tiny-metadata.php +9 -1
- src/class-tiny-notices.php +1 -1
- src/class-tiny-php.php +1 -1
- src/class-tiny-plugin.php +9 -8
- src/class-tiny-settings.php +9 -8
- src/class-tiny-wp-base.php +1 -1
- src/scripts/admin.js +21 -6
- src/views/compress-details-processing.php +2 -2
- src/views/compress-details.php +58 -56
- test/fixtures/{input-large.jpg → input-copyright.jpg} +0 -0
- test/fixtures/input-example.gif +0 -0
- test/fixtures/input-example.pdf +0 -0
- test/fixtures/input-large.png +0 -0
- test/integration/BulkCompressIntegrationTest.php +8 -6
- test/integration/CompressIntegrationTest.php +79 -25
- test/integration/IntegrationTestCase.php +24 -7
- test/integration/SettingsIntegrationTest.php +2 -2
- test/mock-tinypng-webservice/common.php +6 -1
- test/mock-tinypng-webservice/output-copyright.jpg +0 -0
- test/mock-tinypng-webservice/output-large.png +0 -0
- test/mock-tinypng-webservice/output-resized.jpg +0 -0
- test/mock-tinypng-webservice/output-resized.png +0 -0
- test/mock-tinypng-webservice/output.php +19 -10
- test/mock-tinypng-webservice/shrink.php +18 -9
- test/unit/TinySettingsTest.php +1 -1
- tiny-compress-images.php +1 -1
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
# Compress JPEG & PNG images for WordPress
|
4 |
|
5 |
-
Make your website faster by
|
6 |
|
7 |
This plugin automatically optimizes your images by integrating with the
|
8 |
popular image compression services TinyJPG and TinyPNG. You can download the
|
@@ -44,7 +44,7 @@ See https://translate.wordpress.org/projects/wp-plugins/tiny-compress-images.
|
|
44 |
|
45 |
## License
|
46 |
|
47 |
-
Copyright (C) 2015 Voormedia B.V.
|
48 |
|
49 |
This program is free software; you can redistribute it and/or modify
|
50 |
it under the terms of the GNU General Public License as published by
|
2 |
|
3 |
# Compress JPEG & PNG images for WordPress
|
4 |
|
5 |
+
Make your website faster by optimizing your JPEG and PNG images.
|
6 |
|
7 |
This plugin automatically optimizes your images by integrating with the
|
8 |
popular image compression services TinyJPG and TinyPNG. You can download the
|
44 |
|
45 |
## License
|
46 |
|
47 |
+
Copyright (C) 2015-2016 Voormedia B.V.
|
48 |
|
49 |
This program is free software; you can redistribute it and/or modify
|
50 |
it under the terms of the GNU General Public License as published by
|
readme.txt
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
=== Compress JPEG & PNG images ===
|
2 |
Contributors: TinyPNG
|
3 |
Donate link: https://tinypng.com/
|
4 |
-
Tags:
|
5 |
Requires at least: 3.0.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.7.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Speed up your website. Optimize your JPEG and PNG images automatically
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Make your website faster by
|
16 |
|
17 |
= Features =
|
18 |
|
19 |
-
* Automatically
|
20 |
-
*
|
21 |
-
* Easy bulk
|
22 |
* Resize large original images by setting a maximum width and/or height.
|
23 |
-
* Select which thumbnail sizes of an image may be
|
24 |
* Multisite support with a single API key.
|
25 |
-
*
|
26 |
-
*
|
27 |
* Convert CMYK to RGB to save more space and maximize compatibility.
|
28 |
-
*
|
29 |
* No file size limits.
|
30 |
|
31 |
= How does it work? =
|
32 |
|
33 |
-
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
|
34 |
|
35 |
= Getting started =
|
36 |
|
37 |
-
Install this plugin and obtain your free API key from https://tinypng.com/developers. With a free account you can
|
38 |
|
39 |
= Multisite support =
|
40 |
|
@@ -46,62 +46,67 @@ Got questions or feedback? Let us know! Contact us at support@tinypng.com or fin
|
|
46 |
|
47 |
= Contributors =
|
48 |
|
49 |
-
Want to contribute?
|
50 |
|
51 |
== Installation ==
|
52 |
|
53 |
= From your WordPress dashboard =
|
54 |
|
55 |
-
1. Visit
|
56 |
-
2. Search for 'tinypng' and press the Install Now button for the plugin named 'Compress JPEG & PNG images' by 'TinyPNG'.
|
57 |
-
3. Activate the plugin from your Plugins page.
|
58 |
4. Register for an API key on https://tinypng.com/developers.
|
59 |
-
5. Configure the API key in the Settings
|
60 |
-
6. Upload an image and see
|
61 |
|
62 |
= From WordPress.org =
|
63 |
|
64 |
-
1. Download the plugin
|
65 |
-
2. Upload the
|
66 |
3. Activate the plugin from your Plugins page.
|
67 |
4. Register for an API key on https://tinypng.com/developers.
|
68 |
-
5. Configure the API key in the Settings
|
69 |
-
6. Upload an image and see
|
70 |
|
71 |
= Optional configuration =
|
72 |
|
73 |
-
The API key can also be configured in wp-config.php. You can add a TINY_API_KEY constant with your API key. Once set up you will see a message on the media settings page. This will work for normal and multisite WordPress installations.
|
74 |
|
75 |
== Screenshots ==
|
76 |
|
77 |
-
1. Enter your TinyPNG or TinyJPG API key and configure the image sizes you
|
78 |
-
2.
|
79 |
-
3.
|
80 |
-
4.
|
81 |
-
5. Bulk
|
82 |
|
83 |
== Frequently Asked Questions ==
|
84 |
|
85 |
-
= Q: How many images can I
|
86 |
-
A: In a default Wordpress installation you can
|
87 |
|
88 |
-
= Q: What happens to the
|
89 |
-
A: When you remove the TinyPNG plugin all your
|
90 |
|
91 |
= Q: I don't recall uploading 500 photos this month but my limit is already reached. How is this number calculated? =
|
92 |
-
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.
|
93 |
|
94 |
= Q: Is there a file size limit? =
|
95 |
A: No. There are no limitations on the size of the images you want to compress.
|
96 |
|
97 |
-
= Q: What happens when I reach my monthly
|
98 |
-
A: Everything will keep on working, but newly uploaded images will not be
|
99 |
|
100 |
-
= Q: Can I
|
101 |
-
A: Yes! After installing the plugin, go to Media > Compress All Images
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
|
|
105 |
= 1.7.0 =
|
106 |
* Option to preserve copyright information in your original JPEG images.
|
107 |
* Added proxy support for cURL.
|
1 |
=== Compress JPEG & PNG images ===
|
2 |
Contributors: TinyPNG
|
3 |
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.5
|
7 |
+
Stable tag: 1.7.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Speed up your website. Optimize your JPEG and PNG images automatically with TinyPNG.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
Make your website faster by optimizing your JPEG and PNG images. This plugin automatically optimizes all your images by integrating with the popular image compression services TinyJPG and TinyPNG.
|
16 |
|
17 |
= Features =
|
18 |
|
19 |
+
* Automatically optimize new images on upload.
|
20 |
+
* Optimize individual images already in your media library.
|
21 |
+
* Easy bulk optimization of your existing media library.
|
22 |
* Resize large original images by setting a maximum width and/or height.
|
23 |
+
* Select which thumbnail sizes of an image may be optimized.
|
24 |
* Multisite support with a single API key.
|
25 |
+
* See your usage from the media settings and during bulk optimization.
|
26 |
+
* Color profiles are automatically translated to the standard RGB color space.
|
27 |
* Convert CMYK to RGB to save more space and maximize compatibility.
|
28 |
+
* Optimize and resize uploads with the WordPress mobile app.
|
29 |
* No file size limits.
|
30 |
|
31 |
= How does it work? =
|
32 |
|
33 |
+
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 optimization. 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!
|
34 |
|
35 |
= Getting started =
|
36 |
|
37 |
+
Install this plugin and obtain your free API key from https://tinypng.com/developers. With a free account you can optimize **roughly 100 images each month** (based on a regular WordPress installation). The exact number depends on the amount of thumbnails you use. You can change which of the generated thumbnail sizes should be optimized in the *Settings > Media* page. If you’re a heavy user you can optimize more images for a small additional fee per image.
|
38 |
|
39 |
= Multisite support =
|
40 |
|
46 |
|
47 |
= Contributors =
|
48 |
|
49 |
+
Want to contribute? Check out the [Tinify Wordpress plugin on GitHub](https://github.com/tinify/wordpress-plugin).
|
50 |
|
51 |
== Installation ==
|
52 |
|
53 |
= From your WordPress dashboard =
|
54 |
|
55 |
+
1. Visit *Plugins > Add New*.
|
56 |
+
2. Search for 'tinypng' and press the 'Install Now' button for the plugin named 'Compress JPEG & PNG images' by 'TinyPNG'.
|
57 |
+
3. Activate the plugin from your *Plugins* page.
|
58 |
4. Register for an API key on https://tinypng.com/developers.
|
59 |
+
5. Configure the API key in the *Settings > Media* page.
|
60 |
+
6. Upload an image and see the optimization in action!
|
61 |
|
62 |
= From WordPress.org =
|
63 |
|
64 |
+
1. Download the plugin named 'Compress JPEG & PNG images' by 'TinyPNG'.
|
65 |
+
2. Upload the `tiny-compress-images` directory to your `/wp-content/plugins/` directory, using your favorite method (ftp, sftp, scp, etc...)
|
66 |
3. Activate the plugin from your Plugins page.
|
67 |
4. Register for an API key on https://tinypng.com/developers.
|
68 |
+
5. Configure the API key in the *Settings > Media* page.
|
69 |
+
6. Upload an image and see the optimization in action!
|
70 |
|
71 |
= Optional configuration =
|
72 |
|
73 |
+
The API key can also be configured in wp-config.php. You can add a `TINY_API_KEY` constant with your API key. Once set up you will see a message on the media settings page. This will work for normal and multisite WordPress installations.
|
74 |
|
75 |
== Screenshots ==
|
76 |
|
77 |
+
1. Enter your TinyPNG or TinyJPG API key and configure the image sizes you want to optimize.
|
78 |
+
2. In the Media Library you can see how much bytes TinyPNG has saved you. You can also compress additional sizes per image.
|
79 |
+
3. Optimize all images in bulk after installing the plugin or when additional sizes have to be optimized.
|
80 |
+
4. Showing progress during bulk optimization from media library.
|
81 |
+
5. Bulk optimization of all images through the Media > Compress All Images page.
|
82 |
|
83 |
== Frequently Asked Questions ==
|
84 |
|
85 |
+
= Q: How many images can I optimize for free? =
|
86 |
+
A: In a default Wordpress installation you can optimize around 100 images for free each month. WordPress creates different thumbnails of your images which all have to be compressed. Some plugins even add more sizes, so take a look at the *Settings > Media* page before you start optimization.
|
87 |
|
88 |
+
= Q: What happens to the optimized images when I uninstall the plugin? =
|
89 |
+
A: When you remove the TinyPNG plugin all your optimized images will remain optimized.
|
90 |
|
91 |
= Q: I don't recall uploading 500 photos this month but my limit is already reached. How is this number calculated? =
|
92 |
+
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.
|
93 |
|
94 |
= Q: Is there a file size limit? =
|
95 |
A: No. There are no limitations on the size of the images you want to compress.
|
96 |
|
97 |
+
= Q: What happens when I reach my monthly limit? =
|
98 |
+
A: Everything will keep on working, but newly uploaded images will not be optimized. Of course we encourage everyone to sign up for a full subscription.
|
99 |
|
100 |
+
= Q: Can I optimize all existing images in my media library? =
|
101 |
+
A: Yes! After installing the plugin, go to *Media > Compress All Images*, and click on the button to optimize all unoptimized images in your media library.
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 1.7.1 =
|
106 |
+
* Option to preserve gps location and original creation date and time in your original JPEG images.
|
107 |
+
* Option to preserve coyright information in your original PNG images.
|
108 |
+
* Improved handling of unsupported image files (e.g. GIF)
|
109 |
+
|
110 |
= 1.7.0 =
|
111 |
* Option to preserve copyright information in your original JPEG images.
|
112 |
* Added proxy support for cURL.
|
src/class-tiny-compress-curl.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -109,10 +109,11 @@ class Tiny_Compress_Curl extends Tiny_Compress {
|
|
109 |
|
110 |
$response = curl_exec($request);
|
111 |
$header_size = curl_getinfo($request, CURLINFO_HEADER_SIZE);
|
|
|
112 |
$headers = self::parse_headers(substr($response, 0, $header_size));
|
113 |
curl_close($request);
|
114 |
|
115 |
-
return array(substr($response, $header_size), $headers);
|
116 |
}
|
117 |
|
118 |
private function add_proxy_options($url, $options) {
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
109 |
|
110 |
$response = curl_exec($request);
|
111 |
$header_size = curl_getinfo($request, CURLINFO_HEADER_SIZE);
|
112 |
+
$status_code = curl_getinfo($request, CURLINFO_HTTP_CODE);
|
113 |
$headers = self::parse_headers(substr($response, 0, $header_size));
|
114 |
curl_close($request);
|
115 |
|
116 |
+
return array(substr($response, $header_size), $headers, $status_code);
|
117 |
}
|
118 |
|
119 |
private function add_proxy_options($url, $options) {
|
src/class-tiny-compress-fopen.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -19,6 +19,16 @@
|
|
19 |
*/
|
20 |
|
21 |
class Tiny_Compress_Fopen extends Tiny_Compress {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
protected function shrink_options($input) {
|
23 |
return array(
|
24 |
'http' => array(
|
@@ -44,14 +54,7 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
|
|
44 |
$context = stream_context_create($this->shrink_options($input));
|
45 |
$request = @fopen(Tiny_Config::URL, 'r', false, $context);
|
46 |
|
47 |
-
$status_code =
|
48 |
-
if ($http_response_header && count($http_response_header) > 0) {
|
49 |
-
$http_code_values = explode(' ', $http_response_header[0]);
|
50 |
-
if (count($http_code_values) > 1) {
|
51 |
-
$status_code = intval($http_code_values[1]);
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
if (!$request) {
|
56 |
$headers = self::parse_headers($http_response_header);
|
57 |
|
@@ -106,6 +109,7 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
|
|
106 |
$context = stream_context_create($this->output_options($resize_options, $preserve_options));
|
107 |
$request = @fopen($url, 'rb', false, $context);
|
108 |
|
|
|
109 |
if ($request) {
|
110 |
$response = stream_get_contents($request);
|
111 |
$meta_data = stream_get_meta_data($request);
|
@@ -113,8 +117,8 @@ class Tiny_Compress_Fopen extends Tiny_Compress {
|
|
113 |
fclose($request);
|
114 |
} else {
|
115 |
$response = '';
|
116 |
-
$headers =
|
117 |
}
|
118 |
-
return array($response, $headers);
|
119 |
}
|
120 |
}
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
19 |
*/
|
20 |
|
21 |
class Tiny_Compress_Fopen extends Tiny_Compress {
|
22 |
+
private function status_code($header) {
|
23 |
+
if ($header && count($header) > 0) {
|
24 |
+
$http_code_values = explode(' ', $header[0]);
|
25 |
+
if (count($http_code_values) > 1) {
|
26 |
+
return intval($http_code_values[1]);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return null;
|
30 |
+
}
|
31 |
+
|
32 |
protected function shrink_options($input) {
|
33 |
return array(
|
34 |
'http' => array(
|
54 |
$context = stream_context_create($this->shrink_options($input));
|
55 |
$request = @fopen(Tiny_Config::URL, 'r', false, $context);
|
56 |
|
57 |
+
$status_code = self::status_code($http_response_header);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
if (!$request) {
|
59 |
$headers = self::parse_headers($http_response_header);
|
60 |
|
109 |
$context = stream_context_create($this->output_options($resize_options, $preserve_options));
|
110 |
$request = @fopen($url, 'rb', false, $context);
|
111 |
|
112 |
+
$status_code = self::status_code($http_response_header);
|
113 |
if ($request) {
|
114 |
$response = stream_get_contents($request);
|
115 |
$meta_data = stream_get_meta_data($request);
|
117 |
fclose($request);
|
118 |
} else {
|
119 |
$response = '';
|
120 |
+
$headers = self::parse_headers($http_response_header);
|
121 |
}
|
122 |
+
return array($response, $headers, $status_code);
|
123 |
}
|
124 |
}
|
src/class-tiny-compress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -56,15 +56,29 @@ abstract class Tiny_Compress {
|
|
56 |
}
|
57 |
|
58 |
public function compress($input, $resize_options, $preserve_options) {
|
59 |
-
list($details, $headers) = $this->shrink($input);
|
60 |
$this->call_after_compress_callback($details, $headers);
|
61 |
$outputUrl = isset($headers['location']) ? $headers['location'] : null;
|
62 |
if (isset($details['error']) && $details['error']) {
|
63 |
throw new Tiny_Exception($details['message'], $details['error']);
|
|
|
|
|
64 |
} else if ($outputUrl === null) {
|
65 |
throw new Tiny_Exception('Could not find output url', 'OutputNotFound');
|
66 |
}
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
$this->call_after_compress_callback(null, $headers);
|
69 |
if (strlen($output) == 0) {
|
70 |
throw new Tiny_Exception('Could not download output', 'OutputError');
|
@@ -85,8 +99,9 @@ abstract class Tiny_Compress {
|
|
85 |
list($output, $details) = $this->compress(file_get_contents($file), $resize_options, $preserve_options);
|
86 |
file_put_contents($file, $output);
|
87 |
|
|
|
88 |
if ($resize_options) {
|
89 |
-
$details['output']
|
90 |
}
|
91 |
|
92 |
return $details;
|
@@ -139,8 +154,7 @@ abstract class Tiny_Compress {
|
|
139 |
'size' => $size,
|
140 |
'width' => $width,
|
141 |
'height' => $height,
|
142 |
-
'ratio' => round($size / $details['input']['size'], 4)
|
143 |
-
'resized' => true
|
144 |
);
|
145 |
}
|
146 |
}
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
56 |
}
|
57 |
|
58 |
public function compress($input, $resize_options, $preserve_options) {
|
59 |
+
list($details, $headers, $status_code) = $this->shrink($input);
|
60 |
$this->call_after_compress_callback($details, $headers);
|
61 |
$outputUrl = isset($headers['location']) ? $headers['location'] : null;
|
62 |
if (isset($details['error']) && $details['error']) {
|
63 |
throw new Tiny_Exception($details['message'], $details['error']);
|
64 |
+
} else if ($status_code >= 400) {
|
65 |
+
throw new Tiny_Exception('Unexepected error in shrink', 'UnexpectedError');
|
66 |
} else if ($outputUrl === null) {
|
67 |
throw new Tiny_Exception('Could not find output url', 'OutputNotFound');
|
68 |
}
|
69 |
+
|
70 |
+
list($output, $headers, $status_code) = $this->output($outputUrl, $resize_options, $preserve_options);
|
71 |
+
if (isset($headers['content-type']) && substr($headers['content-type'], 0, 16) == 'application/json') {
|
72 |
+
$details = self::decode($output);
|
73 |
+
if (isset($details['error']) && $details['error']) {
|
74 |
+
throw new Tiny_Exception($details['message'], $details['error']);
|
75 |
+
} else {
|
76 |
+
throw new Tiny_Exception('Unknown error', 'UnknownError');
|
77 |
+
}
|
78 |
+
} else if ($status_code >= 400) {
|
79 |
+
throw new Tiny_Exception('Unexepected error in output', 'UnexpectedError');
|
80 |
+
}
|
81 |
+
|
82 |
$this->call_after_compress_callback(null, $headers);
|
83 |
if (strlen($output) == 0) {
|
84 |
throw new Tiny_Exception('Could not download output', 'OutputError');
|
99 |
list($output, $details) = $this->compress(file_get_contents($file), $resize_options, $preserve_options);
|
100 |
file_put_contents($file, $output);
|
101 |
|
102 |
+
$details['output'] = self::update_details($file, $details) + $details['output'];
|
103 |
if ($resize_options) {
|
104 |
+
$details['output']['resized'] = true;
|
105 |
}
|
106 |
|
107 |
return $details;
|
154 |
'size' => $size,
|
155 |
'width' => $width,
|
156 |
'height' => $height,
|
157 |
+
'ratio' => round($size / $details['input']['size'], 4)
|
|
|
158 |
);
|
159 |
}
|
160 |
}
|
src/class-tiny-exception.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
src/class-tiny-metadata.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -116,6 +116,14 @@ class Tiny_Metadata {
|
|
116 |
return $this->name;
|
117 |
}
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
public function get_filename($size=self::ORIGINAL) {
|
120 |
return isset($this->filenames[$size]) ? $this->filenames[$size] : null;
|
121 |
}
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
116 |
return $this->name;
|
117 |
}
|
118 |
|
119 |
+
public function can_be_compressed() {
|
120 |
+
return in_array($this->get_mime_type(), array("image/jpeg", "image/png"));
|
121 |
+
}
|
122 |
+
|
123 |
+
public function get_mime_type() {
|
124 |
+
return get_post_mime_type($this->id);
|
125 |
+
}
|
126 |
+
|
127 |
public function get_filename($size=self::ORIGINAL) {
|
128 |
return isset($this->filenames[$size]) ? $this->filenames[$size] : null;
|
129 |
}
|
src/class-tiny-notices.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
src/class-tiny-php.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
src/class-tiny-plugin.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -26,7 +26,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
26 |
private $twig;
|
27 |
|
28 |
public static function jpeg_quality() {
|
29 |
-
|
30 |
}
|
31 |
|
32 |
public function __construct() {
|
@@ -87,8 +87,9 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
87 |
'wpVersion' => self::wp_version(),
|
88 |
'pluginVersion' => self::plugin_version(),
|
89 |
'L10nAllDone' => __('All images are processed', 'tiny-compress-images'),
|
90 |
-
'L10nBulkAction' => __('Compress Images', 'tiny-compress-images'),
|
91 |
'L10nCompressing' => __('Compressing', 'tiny-compress-images'),
|
|
|
92 |
'L10nCompressions' => __('compressions', 'tiny-compress-images'),
|
93 |
'L10nError' => __('Error', 'tiny-compress-images'),
|
94 |
'L10nInternalError' => __('Internal error', 'tiny-compress-images'),
|
@@ -102,7 +103,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
102 |
$mime_type = get_post_mime_type($attachment_id);
|
103 |
$tiny_metadata = new Tiny_Metadata($attachment_id, $metadata);
|
104 |
|
105 |
-
if ($this->settings->get_compressor() === null ||
|
106 |
return array($tiny_metadata, null);
|
107 |
}
|
108 |
|
@@ -230,7 +231,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
230 |
echo '<div class="wrap" id="tiny-bulk-compress">';
|
231 |
echo '<h2>' . __('Compress JPEG & PNG Images', 'tiny-compress-images') . '</h2>';
|
232 |
if (empty($_POST['tiny-bulk-compress']) && empty($_REQUEST['ids'])) {
|
233 |
-
$result = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type
|
234 |
$image_count = $result[0]['count'];
|
235 |
$sizes_count = count($this->settings->get_active_tinify_sizes());
|
236 |
|
@@ -238,7 +239,7 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
238 |
esc_html_e('Use this tool to compress all images in your media library. Only images that have not been compressed will be compressed.', 'tiny-compress-images');
|
239 |
echo '</p>';
|
240 |
echo '<p>';
|
241 |
-
echo sprintf(esc_html__('We have found %d images in your media library and for each image %d sizes will be compressed.', 'tiny-compress-images'),
|
242 |
$image_count, $sizes_count) . ' ';
|
243 |
echo sprintf(esc_html__('This results in %d compressions at most.', 'tiny-compress-images'), $image_count * $sizes_count);
|
244 |
echo '</p>';
|
@@ -266,10 +267,10 @@ class Tiny_Plugin extends Tiny_WP_Base {
|
|
266 |
}
|
267 |
|
268 |
// Get all ids and names of the images and not the whole objects which will only fill memory
|
269 |
-
$items = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type
|
270 |
|
271 |
echo '<p>';
|
272 |
-
esc_html_e('Please be patient while the images are being
|
273 |
echo '</p><p>';
|
274 |
esc_html_e('You will be notified via this page when the processing is done.', 'tiny-compress-images');
|
275 |
echo "</p>";
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
26 |
private $twig;
|
27 |
|
28 |
public static function jpeg_quality() {
|
29 |
+
return 95;
|
30 |
}
|
31 |
|
32 |
public function __construct() {
|
87 |
'wpVersion' => self::wp_version(),
|
88 |
'pluginVersion' => self::plugin_version(),
|
89 |
'L10nAllDone' => __('All images are processed', 'tiny-compress-images'),
|
90 |
+
'L10nBulkAction' => __('Compress All Images', 'tiny-compress-images'),
|
91 |
'L10nCompressing' => __('Compressing', 'tiny-compress-images'),
|
92 |
+
'L10nCompression' => __('compression', 'tiny-compress-images'),
|
93 |
'L10nCompressions' => __('compressions', 'tiny-compress-images'),
|
94 |
'L10nError' => __('Error', 'tiny-compress-images'),
|
95 |
'L10nInternalError' => __('Internal error', 'tiny-compress-images'),
|
103 |
$mime_type = get_post_mime_type($attachment_id);
|
104 |
$tiny_metadata = new Tiny_Metadata($attachment_id, $metadata);
|
105 |
|
106 |
+
if ($this->settings->get_compressor() === null || !$tiny_metadata->can_be_compressed()) {
|
107 |
return array($tiny_metadata, null);
|
108 |
}
|
109 |
|
231 |
echo '<div class="wrap" id="tiny-bulk-compress">';
|
232 |
echo '<h2>' . __('Compress JPEG & PNG Images', 'tiny-compress-images') . '</h2>';
|
233 |
if (empty($_POST['tiny-bulk-compress']) && empty($_REQUEST['ids'])) {
|
234 |
+
$result = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM $wpdb->posts WHERE post_type = 'attachment' AND (post_mime_type = 'image/jpeg' OR post_mime_type = 'image/png') ORDER BY ID DESC", ARRAY_A);
|
235 |
$image_count = $result[0]['count'];
|
236 |
$sizes_count = count($this->settings->get_active_tinify_sizes());
|
237 |
|
239 |
esc_html_e('Use this tool to compress all images in your media library. Only images that have not been compressed will be compressed.', 'tiny-compress-images');
|
240 |
echo '</p>';
|
241 |
echo '<p>';
|
242 |
+
echo sprintf(esc_html__('We have found %d images in your media library and for each image a maximum of %d sizes will be compressed.', 'tiny-compress-images'),
|
243 |
$image_count, $sizes_count) . ' ';
|
244 |
echo sprintf(esc_html__('This results in %d compressions at most.', 'tiny-compress-images'), $image_count * $sizes_count);
|
245 |
echo '</p>';
|
267 |
}
|
268 |
|
269 |
// Get all ids and names of the images and not the whole objects which will only fill memory
|
270 |
+
$items = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'attachment' AND (post_mime_type = 'image/jpeg' OR post_mime_type = 'image/png') $cond ORDER BY ID DESC", ARRAY_A);
|
271 |
|
272 |
echo '<p>';
|
273 |
+
esc_html_e('Please be patient while the images are being optimized, it can take a while if you have many images. Do not navigate away from this page because it will stop the process.', 'tiny-compress-images');
|
274 |
echo '</p><p>';
|
275 |
esc_html_e('You will be notified via this page when the processing is done.', 'tiny-compress-images');
|
276 |
echo "</p>";
|
src/class-tiny-settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
@@ -55,7 +55,7 @@ class Tiny_Settings extends Tiny_WP_Base {
|
|
55 |
}
|
56 |
|
57 |
$section = self::get_prefixed_name('settings');
|
58 |
-
add_settings_section($section, __('PNG and JPEG
|
59 |
|
60 |
$field = self::get_prefixed_name('api_key');
|
61 |
register_setting('media', $field);
|
@@ -75,7 +75,7 @@ class Tiny_Settings extends Tiny_WP_Base {
|
|
75 |
|
76 |
$field = self::get_prefixed_name('savings');
|
77 |
register_setting('media', $field);
|
78 |
-
add_settings_field($field, __('Savings'), $this->get_method('render_pending_savings'), 'media', $section);
|
79 |
|
80 |
$field = self::get_prefixed_name('preserve_data');
|
81 |
register_setting('media', $field);
|
@@ -288,8 +288,7 @@ class Tiny_Settings extends Tiny_WP_Base {
|
|
288 |
esc_html_e('With these settings no images will be compressed.', 'tiny-compress-images');
|
289 |
} else {
|
290 |
$free_images_per_month = floor( Tiny_Config::MONTHLY_FREE_COMPRESSIONS / $active_image_sizes_count );
|
291 |
-
printf(__('With these settings you can compress <strong> at least %s images </strong> for free each month.',
|
292 |
-
'tiny-compress-images'), $free_images_per_month);
|
293 |
}
|
294 |
echo '</p>';
|
295 |
}
|
@@ -298,7 +297,7 @@ class Tiny_Settings extends Tiny_WP_Base {
|
|
298 |
global $wpdb;
|
299 |
|
300 |
$total_savings = 0;
|
301 |
-
$result = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type
|
302 |
for ($i = 0; $i < sizeof($result); $i++) {
|
303 |
$tiny_metadata = new Tiny_Metadata($result[$i]["ID"]);
|
304 |
$savings = $tiny_metadata->get_savings();
|
@@ -343,11 +342,13 @@ class Tiny_Settings extends Tiny_WP_Base {
|
|
343 |
echo '</p>';
|
344 |
|
345 |
echo '<br>';
|
346 |
-
$this->render_preserve_input("
|
|
|
|
|
347 |
}
|
348 |
|
349 |
public function render_preserve_input($name, $description) {
|
350 |
-
echo '<p>';
|
351 |
$id = sprintf(self::get_prefixed_name('preserve_data_%s'), $name);
|
352 |
$field = sprintf(self::get_prefixed_name('preserve_data[%s]'), $name);
|
353 |
$checked = ( $this->get_preserve_enabled($name) ? ' checked="checked"' : '' );
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
55 |
}
|
56 |
|
57 |
$section = self::get_prefixed_name('settings');
|
58 |
+
add_settings_section($section, __('PNG and JPEG optimization', 'tiny-compress-images'), $this->get_method('render_section'), 'media');
|
59 |
|
60 |
$field = self::get_prefixed_name('api_key');
|
61 |
register_setting('media', $field);
|
75 |
|
76 |
$field = self::get_prefixed_name('savings');
|
77 |
register_setting('media', $field);
|
78 |
+
add_settings_field($field, __('Savings', 'tiny-compress-images'), $this->get_method('render_pending_savings'), 'media', $section);
|
79 |
|
80 |
$field = self::get_prefixed_name('preserve_data');
|
81 |
register_setting('media', $field);
|
288 |
esc_html_e('With these settings no images will be compressed.', 'tiny-compress-images');
|
289 |
} else {
|
290 |
$free_images_per_month = floor( Tiny_Config::MONTHLY_FREE_COMPRESSIONS / $active_image_sizes_count );
|
291 |
+
printf(__('With these settings you can compress <strong> at least %s images </strong> for free each month.', 'tiny-compress-images'), $free_images_per_month);
|
|
|
292 |
}
|
293 |
echo '</p>';
|
294 |
}
|
297 |
global $wpdb;
|
298 |
|
299 |
$total_savings = 0;
|
300 |
+
$result = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND (post_mime_type = 'image/jpeg' OR post_mime_type = 'image/png') ORDER BY ID DESC", ARRAY_A);
|
301 |
for ($i = 0; $i < sizeof($result); $i++) {
|
302 |
$tiny_metadata = new Tiny_Metadata($result[$i]["ID"]);
|
303 |
$savings = $tiny_metadata->get_savings();
|
342 |
echo '</p>';
|
343 |
|
344 |
echo '<br>';
|
345 |
+
$this->render_preserve_input("creation", 'Preserve creation date and time in the original image (JPEG only)') .'<br>';
|
346 |
+
$this->render_preserve_input("copyright", 'Preserve copyright information in the original image') .'<br>';
|
347 |
+
$this->render_preserve_input("location", 'Preserve GPS location in the original image (JPEG only)') .'<br>';
|
348 |
}
|
349 |
|
350 |
public function render_preserve_input($name, $description) {
|
351 |
+
echo '<p class="tiny-preserve">';
|
352 |
$id = sprintf(self::get_prefixed_name('preserve_data_%s'), $name);
|
353 |
$field = sprintf(self::get_prefixed_name('preserve_data[%s]'), $name);
|
354 |
$checked = ( $this->get_preserve_enabled($name) ? ' checked="checked"' : '' );
|
src/class-tiny-wp-base.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
-
* Copyright (C) 2015 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
1 |
<?php
|
2 |
/*
|
3 |
* Tiny Compress Images - WordPress plugin.
|
4 |
+
* Copyright (C) 2015-2016 Voormedia B.V.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it
|
7 |
* under the terms of the GNU General Public License as published by the Free
|
src/scripts/admin.js
CHANGED
@@ -80,12 +80,12 @@
|
|
80 |
} else if (data.failed > 0) {
|
81 |
status.addClass('failed')
|
82 |
row.find('.bar').css('width', '100%')
|
83 |
-
row.find('.percent').html(data.success + " " + tinyCompress.L10nCompressions)
|
84 |
row.find('.progress').attr("title", data.message)
|
85 |
} else {
|
86 |
status.addClass('success')
|
87 |
row.find('.bar').css('width', '100%')
|
88 |
-
row.find('.percent').html(data.success + " " + tinyCompress.L10nCompressions)
|
89 |
}
|
90 |
|
91 |
if (data.status) {
|
@@ -137,7 +137,7 @@
|
|
137 |
bulk_compress_item(items, 0)
|
138 |
}
|
139 |
|
140 |
-
if (adminpage === "upload-php") {
|
141 |
if (typeof jQuery.fn.on === "function") {
|
142 |
jQuery('table').on('click', 'button.tiny-compress', compress_image)
|
143 |
} else {
|
@@ -154,7 +154,7 @@
|
|
154 |
jQuery('<option>').val('tiny_bulk_compress').text(tinyCompress.L10nBulkAction).appendTo('select[name="action2"]')
|
155 |
}
|
156 |
|
157 |
-
if (adminpage === "options-media-php") {
|
158 |
jQuery('#tiny-compress-status').load(ajaxurl + '?action=tiny_compress_status')
|
159 |
jQuery('#tiny-compress-savings').load(ajaxurl + '?action=tiny_compress_savings')
|
160 |
|
@@ -182,8 +182,23 @@
|
|
182 |
elements[i].disabled = !jQuery('#tinypng_resize_original_enabled').prop('checked')
|
183 |
}
|
184 |
}
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
188 |
|
189 |
jQuery('.tiny-notice a.tiny-dismiss').click(dismiss_notice)
|
80 |
} else if (data.failed > 0) {
|
81 |
status.addClass('failed')
|
82 |
row.find('.bar').css('width', '100%')
|
83 |
+
row.find('.percent').html(data.success + " " + (data.success == 1 ? tinyCompress.L10nCompression : tinyCompress.L10nCompressions))
|
84 |
row.find('.progress').attr("title", data.message)
|
85 |
} else {
|
86 |
status.addClass('success')
|
87 |
row.find('.bar').css('width', '100%')
|
88 |
+
row.find('.percent').html(data.success + " " + (data.success == 1 ? tinyCompress.L10nCompression : tinyCompress.L10nCompressions))
|
89 |
}
|
90 |
|
91 |
if (data.status) {
|
137 |
bulk_compress_item(items, 0)
|
138 |
}
|
139 |
|
140 |
+
if (typeof adminpage !== "undefined" && adminpage === "upload-php") {
|
141 |
if (typeof jQuery.fn.on === "function") {
|
142 |
jQuery('table').on('click', 'button.tiny-compress', compress_image)
|
143 |
} else {
|
154 |
jQuery('<option>').val('tiny_bulk_compress').text(tinyCompress.L10nBulkAction).appendTo('select[name="action2"]')
|
155 |
}
|
156 |
|
157 |
+
if (typeof adminpage !== "undefined" && adminpage === "options-media-php") {
|
158 |
jQuery('#tiny-compress-status').load(ajaxurl + '?action=tiny_compress_status')
|
159 |
jQuery('#tiny-compress-savings').load(ajaxurl + '?action=tiny_compress_savings')
|
160 |
|
182 |
elements[i].disabled = !jQuery('#tinypng_resize_original_enabled').prop('checked')
|
183 |
}
|
184 |
}
|
185 |
+
|
186 |
+
function update_preserve_settings() {
|
187 |
+
if (jQuery('#tinypng_sizes_0').prop('checked')) {
|
188 |
+
jQuery('.tiny-preserve').show()
|
189 |
+
} else {
|
190 |
+
jQuery('.tiny-preserve').hide()
|
191 |
+
jQuery('#tinypng_preserve_data_copyright').attr('checked', false)
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
function update_settings() {
|
196 |
+
update_resize_settings()
|
197 |
+
update_preserve_settings()
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
jQuery('#tinypng_sizes_0, #tinypng_resize_original_enabled').click(update_settings)
|
202 |
}
|
203 |
|
204 |
jQuery('.tiny-notice a.tiny-dismiss').click(dismiss_notice)
|
src/views/compress-details-processing.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
<div class="details">
|
3 |
<span class="icon spinner"></span>
|
4 |
<span class="message">
|
5 |
-
<strong
|
6 |
-
<span
|
7 |
</span>
|
8 |
</div>
|
9 |
</div>
|
2 |
<div class="details">
|
3 |
<span class="icon spinner"></span>
|
4 |
<span class="message">
|
5 |
+
<strong><?php echo $compressing ?></strong>
|
6 |
+
<span><?php echo _n('size being compressed', 'sizes being compressed', $compressing, 'tiny-compress-images') ?></span>
|
7 |
</span>
|
8 |
</div>
|
9 |
</div>
|
src/views/compress-details.php
CHANGED
@@ -1,69 +1,71 @@
|
|
1 |
<div class="details-container">
|
2 |
<div class="details" id="tinify-compress-details">
|
3 |
-
<?php if ($
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
</span>
|
20 |
-
|
21 |
-
|
22 |
-
<?php } ?>
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
|
|
61 |
<?php } ?>
|
62 |
</div>
|
63 |
|
64 |
-
<?php if (count($uncompressed) > 0) { ?>
|
65 |
<button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo $tiny_metadata->get_id() ?>">
|
66 |
-
|
67 |
</button>
|
68 |
<?php } ?>
|
69 |
</div>
|
@@ -80,9 +82,9 @@
|
|
80 |
<th><?php esc_html_e('Compressed', 'tiny-compress-images') ?></th>
|
81 |
<th><?php esc_html_e('Date', 'tiny-compress-images') ?></th>
|
82 |
</tr>
|
83 |
-
<?php $i = 0
|
84 |
<?php foreach ($tiny_metadata->get_compressed_sizes() as $size) { ?>
|
85 |
-
<?php $meta = $tiny_metadata->get_value($size)
|
86 |
<tr class="<?php echo ($i % 2 == 0) ? 'even' : 'odd' ?>">
|
87 |
<td>
|
88 |
<?php
|
@@ -104,7 +106,7 @@
|
|
104 |
<td><?php echo size_format($meta["output"]["size"], 1) ?></td>
|
105 |
<td><?php echo human_time_diff($tiny_metadata->get_end_time($size)) . ' ' . esc_html__('ago', 'tiny-compress-images') ?></td>
|
106 |
</tr>
|
107 |
-
<?php $i
|
108 |
<?php } ?>
|
109 |
<?php if ($savings['count'] > 0) { ?>
|
110 |
<tfoot>
|
@@ -120,4 +122,4 @@
|
|
120 |
<p><strong><?php printf(esc_html__('Total savings %s', 'tiny-compress-images'), size_format($savings["input"] - $savings["output"], 1)) ?></strong></p>
|
121 |
</div>
|
122 |
</div>
|
123 |
-
<?php } ?>
|
1 |
<div class="details-container">
|
2 |
<div class="details" id="tinify-compress-details">
|
3 |
+
<?php if ($tiny_metadata->can_be_compressed()) { ?>
|
4 |
+
<?php if ($error) { ?>
|
5 |
+
<span class="icon dashicons dashicons-warning error"></span>
|
6 |
+
<?php } else if ($missing > 0 || $modified > 0) { ?>
|
7 |
+
<span class="icon dashicons dashicons-yes alert"></span>
|
8 |
+
<?php } else if ($tiny_metadata->get_success_count() > 0 && count($uncompressed) > 0) { ?>
|
9 |
+
<span class="icon dashicons dashicons-yes alert"></span>
|
10 |
+
<?php } else if ($tiny_metadata->get_success_count() > 0) { ?>
|
11 |
+
<span class="icon dashicons dashicons-yes success"></span>
|
12 |
+
<?php } ?>
|
13 |
+
<span class="icon spinner hidden"></span>
|
14 |
|
15 |
+
<?php if ($tiny_metadata->get_compressed_count() > 0 || ($tiny_metadata->get_compressed_count() == 0 && count($uncompressed) == 0)) { ?>
|
16 |
+
<span class="message">
|
17 |
+
<strong><?php echo $tiny_metadata->get_compressed_count() ?></strong>
|
18 |
+
<span>
|
19 |
+
<?php echo htmlspecialchars(_n('size compressed', 'sizes compressed', $tiny_metadata->get_compressed_count(), 'tiny-compress-images')) ?>
|
20 |
+
</span>
|
21 |
</span>
|
22 |
+
<br/>
|
23 |
+
<?php } ?>
|
|
|
24 |
|
25 |
+
<?php if ($not_compressed_active > 0) { ?>
|
26 |
+
<span class="message">
|
27 |
+
<?php echo htmlspecialchars(sprintf(_n('%d size not compressed', '%d sizes not compressed', $not_compressed_active, 'tiny-compress-images'), $not_compressed_active)) ?>
|
28 |
+
</span>
|
29 |
+
<br />
|
30 |
+
<?php } ?>
|
31 |
|
32 |
+
<?php if ($missing > 0) { ?>
|
33 |
+
<span class="message">
|
34 |
+
<?php echo htmlspecialchars(sprintf(_n('%d file removed', '%d files removed', $missing, 'tiny-compress-images'), $missing)) ?>
|
35 |
+
</span>
|
36 |
+
<br />
|
37 |
+
<?php } ?>
|
38 |
|
39 |
+
<?php if ($modified > 0) { ?>
|
40 |
+
<span class="message">
|
41 |
+
<?php echo htmlspecialchars(sprintf(_n('%d file modified after compression', '%d files modified after compression', $modified, 'tiny-compress-images'), $modified)) ?>
|
42 |
+
</span>
|
43 |
+
<br />
|
44 |
+
<?php } ?>
|
45 |
|
46 |
+
<?php if ($savings["input"] - $savings["output"]) { ?>
|
47 |
+
<span class="message">
|
48 |
+
<?php printf(esc_html__('Total savings %s', 'tiny-compress-images'), str_replace(" ", " ", size_format($savings["input"] - $savings["output"], 1))) ?>
|
49 |
+
</span>
|
50 |
+
<br />
|
51 |
+
<?php } ?>
|
52 |
|
53 |
+
<?php if ($error) { ?>
|
54 |
+
<span class="message error_message">
|
55 |
+
<?php echo esc_html__('Latest error', 'tiny-compress-images') . ': '. esc_html__($error, 'tiny-compress-images') ?>
|
56 |
+
</span>
|
57 |
+
<br/>
|
58 |
+
<?php } ?>
|
59 |
|
60 |
+
<?php if ($tiny_metadata->get_compressed_count() > 0) { ?>
|
61 |
+
<a class="thickbox message" href="#TB_inline?width=700&height=500&inlineId=modal_<?php echo $tiny_metadata->get_id() ?>">Details</a>
|
62 |
+
<?php } ?>
|
63 |
<?php } ?>
|
64 |
</div>
|
65 |
|
66 |
+
<?php if ($tiny_metadata->can_be_compressed() && count($uncompressed) > 0) { ?>
|
67 |
<button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo $tiny_metadata->get_id() ?>">
|
68 |
+
<?php echo esc_html__('Compress', 'tiny-compress-images') ?>
|
69 |
</button>
|
70 |
<?php } ?>
|
71 |
</div>
|
82 |
<th><?php esc_html_e('Compressed', 'tiny-compress-images') ?></th>
|
83 |
<th><?php esc_html_e('Date', 'tiny-compress-images') ?></th>
|
84 |
</tr>
|
85 |
+
<?php $i = 0 ?>
|
86 |
<?php foreach ($tiny_metadata->get_compressed_sizes() as $size) { ?>
|
87 |
+
<?php $meta = $tiny_metadata->get_value($size) ?>
|
88 |
<tr class="<?php echo ($i % 2 == 0) ? 'even' : 'odd' ?>">
|
89 |
<td>
|
90 |
<?php
|
106 |
<td><?php echo size_format($meta["output"]["size"], 1) ?></td>
|
107 |
<td><?php echo human_time_diff($tiny_metadata->get_end_time($size)) . ' ' . esc_html__('ago', 'tiny-compress-images') ?></td>
|
108 |
</tr>
|
109 |
+
<?php $i++ ?>
|
110 |
<?php } ?>
|
111 |
<?php if ($savings['count'] > 0) { ?>
|
112 |
<tfoot>
|
122 |
<p><strong><?php printf(esc_html__('Total savings %s', 'tiny-compress-images'), size_format($savings["input"] - $savings["output"], 1)) ?></strong></p>
|
123 |
</div>
|
124 |
</div>
|
125 |
+
<?php } ?>
|
test/fixtures/{input-large.jpg → input-copyright.jpg}
RENAMED
Binary file
|
test/fixtures/input-example.gif
ADDED
Binary file
|
test/fixtures/input-example.pdf
ADDED
Binary file
|
test/fixtures/input-large.png
DELETED
Binary file
|
test/integration/BulkCompressIntegrationTest.php
CHANGED
@@ -18,8 +18,8 @@ class BulkCompressIntegrationTest extends IntegrationTestCase {
|
|
18 |
}
|
19 |
|
20 |
public function testBulkCompressActionShouldBePresentInMedia() {
|
21 |
-
$this->
|
22 |
-
$this->assertEquals('Compress Images', self::$driver->findElement(
|
23 |
WebDriverBy::cssSelector('select[name="action"] option[value="tiny_bulk_compress"]')
|
24 |
)->getText());
|
25 |
}
|
@@ -29,12 +29,15 @@ class BulkCompressIntegrationTest extends IntegrationTestCase {
|
|
29 |
$this->enable_compression_sizes(array());
|
30 |
|
31 |
for ($i = 0; $i < $normal; $i++) {
|
32 |
-
$this->
|
33 |
}
|
34 |
for ($i = 0; $i < $large; $i++) {
|
35 |
-
$this->
|
36 |
}
|
37 |
|
|
|
|
|
|
|
38 |
$this->enable_compression_sizes(array('thumbnail', 'medium', 'large'));
|
39 |
}
|
40 |
|
@@ -70,10 +73,9 @@ class BulkCompressIntegrationTest extends IntegrationTestCase {
|
|
70 |
$filenames = array_map('innerText', $elements);
|
71 |
|
72 |
$this->assertEquals(2, count($filenames));
|
73 |
-
$this->assertContains('input-large', $filenames);
|
74 |
$this->assertContains('input-example', $filenames);
|
75 |
|
76 |
$this->assertEquals('2', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-progress span'))->getText());
|
77 |
-
$this->assertEquals('
|
78 |
}
|
79 |
}
|
18 |
}
|
19 |
|
20 |
public function testBulkCompressActionShouldBePresentInMedia() {
|
21 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
22 |
+
$this->assertEquals('Compress All Images', self::$driver->findElement(
|
23 |
WebDriverBy::cssSelector('select[name="action"] option[value="tiny_bulk_compress"]')
|
24 |
)->getText());
|
25 |
}
|
29 |
$this->enable_compression_sizes(array());
|
30 |
|
31 |
for ($i = 0; $i < $normal; $i++) {
|
32 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.jpg');
|
33 |
}
|
34 |
for ($i = 0; $i < $large; $i++) {
|
35 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
36 |
}
|
37 |
|
38 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.gif');
|
39 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.pdf');
|
40 |
+
|
41 |
$this->enable_compression_sizes(array('thumbnail', 'medium', 'large'));
|
42 |
}
|
43 |
|
73 |
$filenames = array_map('innerText', $elements);
|
74 |
|
75 |
$this->assertEquals(2, count($filenames));
|
|
|
76 |
$this->assertContains('input-example', $filenames);
|
77 |
|
78 |
$this->assertEquals('2', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-progress span'))->getText());
|
79 |
+
$this->assertEquals('4', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-status span'))->getText());
|
80 |
}
|
81 |
}
|
test/integration/CompressIntegrationTest.php
CHANGED
@@ -19,7 +19,7 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
19 |
public function testInvalidCredentialsShouldStillUploadImage()
|
20 |
{
|
21 |
$this->set_api_key('1234');
|
22 |
-
$this->
|
23 |
$this->assertContains('input-example',
|
24 |
self::$driver->findElement(WebDriverBy::xpath('//img[contains(@src, "input-example")]'))->getAttribute('src'));
|
25 |
}
|
@@ -27,14 +27,14 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
27 |
public function testInvalidCredentialsShouldShowError()
|
28 |
{
|
29 |
$this->set_api_key('1234');
|
30 |
-
$this->
|
31 |
$this->assertContains('Latest error: Credentials are invalid',
|
32 |
self::$driver->findElement(WebDriverBy::id('tinify-compress-details'))->getText());
|
33 |
}
|
34 |
|
35 |
public function testShrink() {
|
36 |
$this->set_api_key('PNG123');
|
37 |
-
$this->
|
38 |
$this->assertContains('sizes compressed',
|
39 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
|
40 |
}
|
@@ -42,7 +42,7 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
42 |
public function testCompressButton() {
|
43 |
$this->enable_compression_sizes(array('medium'));
|
44 |
$this->set_api_key('PNG123');
|
45 |
-
$this->
|
46 |
$this->enable_compression_sizes(array('medium', 'large'));
|
47 |
|
48 |
self::$driver->get(wordpress('/wp-admin/upload.php'));
|
@@ -57,14 +57,14 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
57 |
|
58 |
public function testLimitReached() {
|
59 |
$this->set_api_key('LIMIT123');
|
60 |
-
$this->
|
61 |
$this->assertContains('Latest error: Your monthly limit has been exceeded',
|
62 |
self::$driver->findElement(WebDriverBy::cssSelector('span.error_message'))->getText());
|
63 |
}
|
64 |
|
65 |
public function testLimitReachedDismisses() {
|
66 |
$this->set_api_key('LIMIT123');
|
67 |
-
$this->
|
68 |
self::$driver->findElement(WebDriverBy::cssSelector('.tiny-notice button, .tiny-notice a.tiny-dismiss'))->click();
|
69 |
self::$driver->wait(2)->until(WebDriverExpectedCondition::invisibilityOfElementWithText(
|
70 |
WebDriverBy::cssSelector('.tiny-dismiss'), 'Dismiss'));
|
@@ -75,7 +75,7 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
75 |
|
76 |
public function testIncorrectJsonButton() {
|
77 |
$this->enable_compression_sizes(array());
|
78 |
-
$this->
|
79 |
$this->enable_compression_sizes(array('medium', 'large'));
|
80 |
|
81 |
$this->set_api_key('JSON1234');
|
@@ -87,36 +87,36 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
87 |
}
|
88 |
|
89 |
public function testResizeFitShouldDisplayResizedTextInMediaLibrary() {
|
90 |
-
$this->set_api_key('
|
91 |
$this->enable_resize(300, 200);
|
92 |
-
$this->
|
93 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
94 |
$this->assertContains('resized to 300x200',
|
95 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
96 |
}
|
97 |
|
98 |
public function testResizeFitShouldDisplayResizedTextInEditScreen() {
|
99 |
-
$this->set_api_key('
|
100 |
$this->enable_resize(300, 200);
|
101 |
-
$this->
|
102 |
$this->view_edit_image();
|
103 |
$this->assertContains('Dimensions: 300 × 200',
|
104 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
105 |
}
|
106 |
|
107 |
public function testResizeScaleShouldDisplayResizedTextInMediaLibrary() {
|
108 |
-
$this->set_api_key('
|
109 |
$this->enable_resize(0, 200);
|
110 |
-
$this->
|
111 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
112 |
$this->assertContains('resized to 300x200', self::$driver->findElement(
|
113 |
WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
114 |
}
|
115 |
|
116 |
public function testResizeScaleShouldDisplayResizedTextInEditScreen() {
|
117 |
-
$this->set_api_key('
|
118 |
$this->enable_resize(0, 200);
|
119 |
-
$this->
|
120 |
$this->view_edit_image();
|
121 |
$this->assertContains('Dimensions: 300 × 200',
|
122 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
@@ -124,9 +124,9 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
124 |
|
125 |
public function testResizeNotNeededShouldNotDisplayResizedTextInMediaLibrary()
|
126 |
{
|
127 |
-
$this->set_api_key('
|
128 |
$this->enable_resize(30000, 20000);
|
129 |
-
$this->
|
130 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
131 |
$this->assertNotContains('resized',
|
132 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
@@ -134,20 +134,20 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
134 |
|
135 |
public function testResizeNotNeededShouldDisplayOriginalDimensionsInEditScreen()
|
136 |
{
|
137 |
-
$this->set_api_key('
|
138 |
$this->enable_resize(30000, 20000);
|
139 |
-
$this->
|
140 |
$this->view_edit_image();
|
141 |
-
$this->assertContains('Dimensions: 1080 ×
|
142 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
143 |
}
|
144 |
|
145 |
public function testResizeDisabledShouldNotDisplayResizedTextInMediaLibrary()
|
146 |
{
|
147 |
-
$this->set_api_key('
|
148 |
$this->enable_resize(300, 200);
|
149 |
$this->disable_resize();
|
150 |
-
$this->
|
151 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
152 |
$this->assertNotContains('resized',
|
153 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
@@ -155,12 +155,66 @@ class CompressIntegrationTest extends IntegrationTestCase {
|
|
155 |
|
156 |
public function testResizeDisabledShouldDisplayOriginalDimensionsInEditScreen()
|
157 |
{
|
158 |
-
$this->set_api_key('
|
159 |
$this->enable_resize(300, 200);
|
160 |
$this->disable_resize();
|
161 |
-
$this->
|
162 |
$this->view_edit_image();
|
163 |
-
$this->assertContains('Dimensions: 1080 ×
|
164 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
19 |
public function testInvalidCredentialsShouldStillUploadImage()
|
20 |
{
|
21 |
$this->set_api_key('1234');
|
22 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
23 |
$this->assertContains('input-example',
|
24 |
self::$driver->findElement(WebDriverBy::xpath('//img[contains(@src, "input-example")]'))->getAttribute('src'));
|
25 |
}
|
27 |
public function testInvalidCredentialsShouldShowError()
|
28 |
{
|
29 |
$this->set_api_key('1234');
|
30 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
31 |
$this->assertContains('Latest error: Credentials are invalid',
|
32 |
self::$driver->findElement(WebDriverBy::id('tinify-compress-details'))->getText());
|
33 |
}
|
34 |
|
35 |
public function testShrink() {
|
36 |
$this->set_api_key('PNG123');
|
37 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
38 |
$this->assertContains('sizes compressed',
|
39 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
|
40 |
}
|
42 |
public function testCompressButton() {
|
43 |
$this->enable_compression_sizes(array('medium'));
|
44 |
$this->set_api_key('PNG123');
|
45 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
46 |
$this->enable_compression_sizes(array('medium', 'large'));
|
47 |
|
48 |
self::$driver->get(wordpress('/wp-admin/upload.php'));
|
57 |
|
58 |
public function testLimitReached() {
|
59 |
$this->set_api_key('LIMIT123');
|
60 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
61 |
$this->assertContains('Latest error: Your monthly limit has been exceeded',
|
62 |
self::$driver->findElement(WebDriverBy::cssSelector('span.error_message'))->getText());
|
63 |
}
|
64 |
|
65 |
public function testLimitReachedDismisses() {
|
66 |
$this->set_api_key('LIMIT123');
|
67 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
68 |
self::$driver->findElement(WebDriverBy::cssSelector('.tiny-notice button, .tiny-notice a.tiny-dismiss'))->click();
|
69 |
self::$driver->wait(2)->until(WebDriverExpectedCondition::invisibilityOfElementWithText(
|
70 |
WebDriverBy::cssSelector('.tiny-dismiss'), 'Dismiss'));
|
75 |
|
76 |
public function testIncorrectJsonButton() {
|
77 |
$this->enable_compression_sizes(array());
|
78 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
79 |
$this->enable_compression_sizes(array('medium', 'large'));
|
80 |
|
81 |
$this->set_api_key('JSON1234');
|
87 |
}
|
88 |
|
89 |
public function testResizeFitShouldDisplayResizedTextInMediaLibrary() {
|
90 |
+
$this->set_api_key('PNG123');
|
91 |
$this->enable_resize(300, 200);
|
92 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
93 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
94 |
$this->assertContains('resized to 300x200',
|
95 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
96 |
}
|
97 |
|
98 |
public function testResizeFitShouldDisplayResizedTextInEditScreen() {
|
99 |
+
$this->set_api_key('PNG123');
|
100 |
$this->enable_resize(300, 200);
|
101 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
102 |
$this->view_edit_image();
|
103 |
$this->assertContains('Dimensions: 300 × 200',
|
104 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
105 |
}
|
106 |
|
107 |
public function testResizeScaleShouldDisplayResizedTextInMediaLibrary() {
|
108 |
+
$this->set_api_key('PNG123');
|
109 |
$this->enable_resize(0, 200);
|
110 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
111 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
112 |
$this->assertContains('resized to 300x200', self::$driver->findElement(
|
113 |
WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
114 |
}
|
115 |
|
116 |
public function testResizeScaleShouldDisplayResizedTextInEditScreen() {
|
117 |
+
$this->set_api_key('PNG123');
|
118 |
$this->enable_resize(0, 200);
|
119 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
120 |
$this->view_edit_image();
|
121 |
$this->assertContains('Dimensions: 300 × 200',
|
122 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
124 |
|
125 |
public function testResizeNotNeededShouldNotDisplayResizedTextInMediaLibrary()
|
126 |
{
|
127 |
+
$this->set_api_key('PNG123');
|
128 |
$this->enable_resize(30000, 20000);
|
129 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
130 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
131 |
$this->assertNotContains('resized',
|
132 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
134 |
|
135 |
public function testResizeNotNeededShouldDisplayOriginalDimensionsInEditScreen()
|
136 |
{
|
137 |
+
$this->set_api_key('PNG123');
|
138 |
$this->enable_resize(30000, 20000);
|
139 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
140 |
$this->view_edit_image();
|
141 |
+
$this->assertContains('Dimensions: 1080 × 720',
|
142 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
143 |
}
|
144 |
|
145 |
public function testResizeDisabledShouldNotDisplayResizedTextInMediaLibrary()
|
146 |
{
|
147 |
+
$this->set_api_key('PNG123');
|
148 |
$this->enable_resize(300, 200);
|
149 |
$this->disable_resize();
|
150 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
151 |
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
|
152 |
$this->assertNotContains('resized',
|
153 |
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
|
155 |
|
156 |
public function testResizeDisabledShouldDisplayOriginalDimensionsInEditScreen()
|
157 |
{
|
158 |
+
$this->set_api_key('PNG123');
|
159 |
$this->enable_resize(300, 200);
|
160 |
$this->disable_resize();
|
161 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
162 |
$this->view_edit_image();
|
163 |
+
$this->assertContains('Dimensions: 1080 × 720',
|
164 |
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
|
165 |
}
|
166 |
+
|
167 |
+
public function testPreserveCopyrightShouldDisplayCorrectImageSizeInMediaLibrary()
|
168 |
+
{
|
169 |
+
$this->set_api_key('PRESERVEJPG123');
|
170 |
+
$this->enable_preserve(array('copyright'));
|
171 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-copyright.jpg');
|
172 |
+
$this->assertNotContains('files modified after compression',
|
173 |
+
self::$driver->findElement(WebDriverBy::cssSelector('div#tinify-compress-details'))->getText());
|
174 |
+
}
|
175 |
+
|
176 |
+
public function testDifferentImageFormatFileShouldNotShowCompressInfoInMediaLibrary()
|
177 |
+
{
|
178 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.gif');
|
179 |
+
$this->assertEquals('',
|
180 |
+
self::$driver->findElement(WebDriverBy::cssSelector('div#tinify-compress-details'))->getText());
|
181 |
+
}
|
182 |
+
|
183 |
+
public function testNonImageFileShouldNotShowCompressInfoInMediaLibrary()
|
184 |
+
{
|
185 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.pdf');
|
186 |
+
$this->assertEquals('',
|
187 |
+
self::$driver->findElement(WebDriverBy::cssSelector('div#tinify-compress-details'))->getText());
|
188 |
+
}
|
189 |
+
|
190 |
+
public function testGatewayTimeoutShouldBeDetectedInShrink()
|
191 |
+
{
|
192 |
+
$this->enable_compression_sizes(array('medium'));
|
193 |
+
$this->set_api_key('GATEWAYTIMEOUT');
|
194 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
195 |
+
$this->assertContains('JSON: Syntax error [4]',
|
196 |
+
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
|
197 |
+
}
|
198 |
+
|
199 |
+
public function testGatewayTimeoutShouldBeDetectedInOutput()
|
200 |
+
{
|
201 |
+
$this->enable_compression_sizes(array('medium'));
|
202 |
+
$this->enable_preserve(array('copyright'));
|
203 |
+
$this->set_api_key('PNG123_GATEWAYTIMEOUT');
|
204 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
205 |
+
self::$driver->takeScreenshot("/Users/jacobmiddag/Downloads/ss2.png");
|
206 |
+
$this->assertContains('Unexepected error in output',
|
207 |
+
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
|
208 |
+
}
|
209 |
+
|
210 |
+
public function testErrorShouldBeDetectedInOutput()
|
211 |
+
{
|
212 |
+
$this->enable_compression_sizes(array('medium'));
|
213 |
+
$this->enable_preserve(array('copyright'));
|
214 |
+
$this->set_api_key('PNG123_INVALID');
|
215 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
216 |
+
self::$driver->takeScreenshot("/Users/jacobmiddag/Downloads/ss3.png");
|
217 |
+
$this->assertContains("Metadata key 'author' not supported",
|
218 |
+
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
|
219 |
+
}
|
220 |
}
|
test/integration/IntegrationTestCase.php
CHANGED
@@ -16,7 +16,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase {
|
|
16 |
self::$driver = RemoteWebDriver::createBySessionId($GLOBALS['global_session_id'], $GLOBALS['global_webdriver_host']);
|
17 |
}
|
18 |
|
19 |
-
protected function
|
20 |
self::$driver->get(wordpress('/wp-admin/media-new.php?browser-uploader&flash=0'));
|
21 |
$links = self::$driver->findElements(WebDriverBy::xpath('//a[text()="browser uploader"]'));
|
22 |
if (count($links) > 0) {
|
@@ -30,11 +30,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase {
|
|
30 |
$file_input->setFileDetector(new UselessFileDetector());
|
31 |
$file_input->sendKeys($path);
|
32 |
self::$driver->findElement(WebDriverBy::xpath('//input[@value="Upload"]'))->click();
|
33 |
-
|
34 |
-
$file_name = array_pop($path_elements);
|
35 |
-
$image_elements = explode('.', $file_name);
|
36 |
-
$image_name = $image_elements[0];
|
37 |
-
self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xpath('//img[contains(@src, "' . $image_name . '")]')));
|
38 |
}
|
39 |
|
40 |
protected function set_api_key($api_key) {
|
@@ -94,7 +90,28 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase {
|
|
94 |
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
|
95 |
}
|
96 |
|
97 |
-
protected function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$url = wordpress('/wp-admin/upload.php');
|
99 |
if (self::$driver->getCurrentUrl() != $url) {
|
100 |
self::$driver->get($url);
|
16 |
self::$driver = RemoteWebDriver::createBySessionId($GLOBALS['global_session_id'], $GLOBALS['global_webdriver_host']);
|
17 |
}
|
18 |
|
19 |
+
protected function upload_media($path) {
|
20 |
self::$driver->get(wordpress('/wp-admin/media-new.php?browser-uploader&flash=0'));
|
21 |
$links = self::$driver->findElements(WebDriverBy::xpath('//a[text()="browser uploader"]'));
|
22 |
if (count($links) > 0) {
|
30 |
$file_input->setFileDetector(new UselessFileDetector());
|
31 |
$file_input->sendKeys($path);
|
32 |
self::$driver->findElement(WebDriverBy::xpath('//input[@value="Upload"]'))->click();
|
33 |
+
self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xpath('//h1[contains(text(),"Media Library")]')));
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
protected function set_api_key($api_key) {
|
90 |
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
|
91 |
}
|
92 |
|
93 |
+
protected function enable_preserve($keys) {
|
94 |
+
$url = wordpress('/wp-admin/options-media.php');
|
95 |
+
if (self::$driver->getCurrentUrl() != $url) {
|
96 |
+
self::$driver->get($url);
|
97 |
+
}
|
98 |
+
$elements = self::$driver->findElements(WebDriverBy::xpath('//input[starts-with(@id, "tinypng_preserve_data")]'));
|
99 |
+
foreach($elements as $element) {
|
100 |
+
$key = str_replace('tinypng_preserve_data_', '', $element->getAttribute('id'));
|
101 |
+
if (in_array($key, $keys)) {
|
102 |
+
if (!$element->getAttribute('checked')) {
|
103 |
+
$element->click();
|
104 |
+
}
|
105 |
+
} else {
|
106 |
+
if ($element->getAttribute('checked')) {
|
107 |
+
$element->click();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
|
112 |
+
}
|
113 |
+
|
114 |
+
protected function view_edit_image($image_title = 'input-example') {
|
115 |
$url = wordpress('/wp-admin/upload.php');
|
116 |
if (self::$driver->getCurrentUrl() != $url) {
|
117 |
self::$driver->get($url);
|
test/integration/SettingsIntegrationTest.php
CHANGED
@@ -20,7 +20,7 @@ class SettingsIntegrationTest extends IntegrationTestCase {
|
|
20 |
{
|
21 |
$headings = self::$driver->findElements(WebDriverBy::cssSelector('h1, h2, h3, h4'));
|
22 |
$texts = array_map('innerText', $headings);
|
23 |
-
$this->assertContains('PNG and JPEG
|
24 |
}
|
25 |
|
26 |
public function testApiKeyInputPresence() {
|
@@ -180,7 +180,7 @@ class SettingsIntegrationTest extends IntegrationTestCase {
|
|
180 |
public function testShouldShowSavings() {
|
181 |
reset_webservice();
|
182 |
$this->set_api_key('PNG123');
|
183 |
-
$this->
|
184 |
self::$driver->get(wordpress('/wp-admin/options-media.php'));
|
185 |
self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#tiny-compress-savings p')));
|
186 |
$elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-savings'))->findElements(WebDriverBy::tagName('p'));
|
20 |
{
|
21 |
$headings = self::$driver->findElements(WebDriverBy::cssSelector('h1, h2, h3, h4'));
|
22 |
$texts = array_map('innerText', $headings);
|
23 |
+
$this->assertContains('PNG and JPEG optimization', $texts);
|
24 |
}
|
25 |
|
26 |
public function testApiKeyInputPresence() {
|
180 |
public function testShouldShowSavings() {
|
181 |
reset_webservice();
|
182 |
$this->set_api_key('PNG123');
|
183 |
+
$this->upload_media(dirname(__FILE__) . '/../fixtures/input-example.png');
|
184 |
self::$driver->get(wordpress('/wp-admin/options-media.php'));
|
185 |
self::$driver->wait(2)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#tiny-compress-savings p')));
|
186 |
$elements = self::$driver->findElement(WebDriverBy::id('tiny-compress-savings'))->findElements(WebDriverBy::tagName('p'));
|
test/mock-tinypng-webservice/common.php
CHANGED
@@ -39,7 +39,12 @@ function mock_invalid_response() {
|
|
39 |
|
40 |
$response = array(
|
41 |
"error" => "Unauthorized",
|
42 |
-
"message" => "Credentials are invalid"
|
43 |
);
|
44 |
return json_encode($response);
|
45 |
}
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
$response = array(
|
41 |
"error" => "Unauthorized",
|
42 |
+
"message" => "Credentials are invalid "
|
43 |
);
|
44 |
return json_encode($response);
|
45 |
}
|
46 |
+
|
47 |
+
function mock_service_unavailable_response() {
|
48 |
+
header('HTTP/1.1 503 Service unavailable');
|
49 |
+
return 'HTTP Error 503. The service is unavailable';
|
50 |
+
}
|
test/mock-tinypng-webservice/output-copyright.jpg
ADDED
Binary file
|
test/mock-tinypng-webservice/output-large.png
DELETED
Binary file
|
test/mock-tinypng-webservice/output-resized.jpg
DELETED
Binary file
|
test/mock-tinypng-webservice/output-resized.png
ADDED
Binary file
|
test/mock-tinypng-webservice/output.php
CHANGED
@@ -10,30 +10,39 @@ if (preg_match('#output/.+[.](png|jpg)$#', $_SERVER['REQUEST_URI'], $match)) {
|
|
10 |
} else {
|
11 |
$file = null;
|
12 |
}
|
|
|
13 |
|
14 |
$api_key = get_api_key();
|
15 |
if (!is_null($api_key)) {
|
16 |
$data = get_json_body();
|
17 |
-
if (is_null($data) || $api_key != 'JPG123') {
|
18 |
-
mock_invalid_response();
|
19 |
-
ob_end_flush();
|
20 |
-
exit();
|
21 |
-
}
|
22 |
-
|
23 |
$resize = $data->resize;
|
24 |
if ($resize->method) {
|
25 |
$file = "output-resized.$ext";
|
26 |
-
|
27 |
-
|
28 |
}
|
29 |
}
|
30 |
|
31 |
-
if ($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
header("Content-Type: $mime");
|
33 |
header('Content-Disposition: attachment');
|
|
|
|
|
|
|
34 |
readfile($file);
|
35 |
} else {
|
36 |
header("HTTP/1.1 404 Not Found");
|
37 |
}
|
38 |
|
39 |
-
ob_end_flush();
|
10 |
} else {
|
11 |
$file = null;
|
12 |
}
|
13 |
+
$headers = [];
|
14 |
|
15 |
$api_key = get_api_key();
|
16 |
if (!is_null($api_key)) {
|
17 |
$data = get_json_body();
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
$resize = $data->resize;
|
19 |
if ($resize->method) {
|
20 |
$file = "output-resized.$ext";
|
21 |
+
$headers["Image-Width"] = $resize->width;
|
22 |
+
$headers["Image-Height"] = $resize->height;
|
23 |
}
|
24 |
}
|
25 |
|
26 |
+
if (strpos($api_key, 'GATEWAYTIMEOUT') !== false) {
|
27 |
+
echo mock_service_unavailable_response();
|
28 |
+
} else if (strpos($api_key, 'INVALID') !== false) {
|
29 |
+
header('HTTP/1.1 400 Bad Request');
|
30 |
+
header("Content-Type: application/json; charset=utf-8");
|
31 |
+
|
32 |
+
$response = array(
|
33 |
+
"error" => "JSON validation error",
|
34 |
+
"message" => "Metadata key 'author' not supported"
|
35 |
+
);
|
36 |
+
echo json_encode($response);
|
37 |
+
} else if ($file && file_exists($file)) {
|
38 |
header("Content-Type: $mime");
|
39 |
header('Content-Disposition: attachment');
|
40 |
+
foreach ($headers as $name => $value) {
|
41 |
+
header("$name: $value");
|
42 |
+
}
|
43 |
readfile($file);
|
44 |
} else {
|
45 |
header("HTTP/1.1 404 Not Found");
|
46 |
}
|
47 |
|
48 |
+
ob_end_flush();
|
test/mock-tinypng-webservice/shrink.php
CHANGED
@@ -28,24 +28,24 @@ function mock_jpg_response() {
|
|
28 |
header("Compression-Count: {$session['Compression-Count']}");
|
29 |
|
30 |
$response = array(
|
31 |
-
"input" => array("size" => 15391, "type" => "image/
|
32 |
-
"output" => array("size" => 13910, "type" => "image/
|
33 |
);
|
34 |
return json_encode($response);
|
35 |
}
|
36 |
|
37 |
-
function
|
38 |
global $session;
|
39 |
|
40 |
$session['Compression-Count'] += 1;
|
41 |
header('HTTP/1.1 201 Created');
|
42 |
-
header("Location: http://webservice/output/
|
43 |
header("Content-Type: application/json; charset=utf-8");
|
44 |
header("Compression-Count: {$session['Compression-Count']}");
|
45 |
|
46 |
$response = array(
|
47 |
-
"input" => array("size" =>
|
48 |
-
"output" => array("size" =>
|
49 |
);
|
50 |
return json_encode($response);
|
51 |
}
|
@@ -59,7 +59,7 @@ function mock_empty_response() {
|
|
59 |
|
60 |
$response = array(
|
61 |
"error" => "InputMissing",
|
62 |
-
"message" => "
|
63 |
);
|
64 |
return json_encode($response);
|
65 |
}
|
@@ -89,8 +89,9 @@ function mock_invalid_json_response() {
|
|
89 |
return '{invalid: json}';
|
90 |
}
|
91 |
|
|
|
92 |
$api_key = get_api_key();
|
93 |
-
if ($api_key == 'PNG123') {
|
94 |
if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
|
95 |
echo mock_empty_response();
|
96 |
} else {
|
@@ -102,6 +103,12 @@ if ($api_key == 'PNG123') {
|
|
102 |
} else {
|
103 |
echo mock_jpg_response();
|
104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
} else if ($api_key == 'JSON1234') {
|
106 |
if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
|
107 |
echo mock_empty_response();
|
@@ -110,8 +117,10 @@ if ($api_key == 'PNG123') {
|
|
110 |
}
|
111 |
} else if ($api_key == 'LIMIT123') {
|
112 |
echo mock_limit_reached_response();
|
|
|
|
|
113 |
} else {
|
114 |
echo mock_invalid_response();
|
115 |
}
|
116 |
|
117 |
-
ob_end_flush();
|
28 |
header("Compression-Count: {$session['Compression-Count']}");
|
29 |
|
30 |
$response = array(
|
31 |
+
"input" => array("size" => 15391, "type" => "image/jpeg"),
|
32 |
+
"output" => array("size" => 13910, "type" => "image/jpeg", "ratio" => 0.904)
|
33 |
);
|
34 |
return json_encode($response);
|
35 |
}
|
36 |
|
37 |
+
function mock_preserve_jpg_copyright_response() {
|
38 |
global $session;
|
39 |
|
40 |
$session['Compression-Count'] += 1;
|
41 |
header('HTTP/1.1 201 Created');
|
42 |
+
header("Location: http://webservice/output/copyright.jpg");
|
43 |
header("Content-Type: application/json; charset=utf-8");
|
44 |
header("Compression-Count: {$session['Compression-Count']}");
|
45 |
|
46 |
$response = array(
|
47 |
+
"input" => array("size" => 110329, "type" => "image/jpeg"),
|
48 |
+
"output" => array("size" => 97835, "type" => "image/jpeg", "ratio" => 0.8868)
|
49 |
);
|
50 |
return json_encode($response);
|
51 |
}
|
59 |
|
60 |
$response = array(
|
61 |
"error" => "InputMissing",
|
62 |
+
"message" => "File is empty"
|
63 |
);
|
64 |
return json_encode($response);
|
65 |
}
|
89 |
return '{invalid: json}';
|
90 |
}
|
91 |
|
92 |
+
|
93 |
$api_key = get_api_key();
|
94 |
+
if (substr($api_key, 0, 6) == 'PNG123') {
|
95 |
if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
|
96 |
echo mock_empty_response();
|
97 |
} else {
|
103 |
} else {
|
104 |
echo mock_jpg_response();
|
105 |
}
|
106 |
+
} else if ($api_key == 'PRESERVEJPG123') {
|
107 |
+
if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
|
108 |
+
echo mock_empty_response();
|
109 |
+
} else {
|
110 |
+
echo mock_preserve_jpg_copyright_response();
|
111 |
+
}
|
112 |
} else if ($api_key == 'JSON1234') {
|
113 |
if (intval($_SERVER['CONTENT_LENGTH']) == 0) {
|
114 |
echo mock_empty_response();
|
117 |
}
|
118 |
} else if ($api_key == 'LIMIT123') {
|
119 |
echo mock_limit_reached_response();
|
120 |
+
} else if ($api_key == 'GATEWAYTIMEOUT') {
|
121 |
+
echo mock_service_unavailable_response();
|
122 |
} else {
|
123 |
echo mock_invalid_response();
|
124 |
}
|
125 |
|
126 |
+
ob_end_flush();
|
test/unit/TinySettingsTest.php
CHANGED
@@ -23,7 +23,7 @@ class Tiny_Settings_Test extends TinyTestCase {
|
|
23 |
|
24 |
public function testAdminInitShouldAddSettingsSection() {
|
25 |
$this->assertEquals(array(
|
26 |
-
array('tinypng_settings', 'PNG and JPEG
|
27 |
), $this->wp->getCalls('add_settings_section'));
|
28 |
}
|
29 |
|
23 |
|
24 |
public function testAdminInitShouldAddSettingsSection() {
|
25 |
$this->assertEquals(array(
|
26 |
+
array('tinypng_settings', 'PNG and JPEG optimization', array($this->subject, 'render_section'), 'media'),
|
27 |
), $this->wp->getCalls('add_settings_section'));
|
28 |
}
|
29 |
|
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: 1.7.
|
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: 1.7.1
|
6 |
* Author: TinyPNG
|
7 |
* Author URI: https://tinypng.com
|
8 |
* Text Domain: tiny-compress-images
|