Kraken.io Image Optimizer - Version 1.0.5

Version Description

  • Fixed CURL issues related to latest PHP versions.
  • Can now optimize filenames with non-Latin alphabet (such as Germanic umlauts, Cyrillic alphabet, etc).
  • Performance improvement when optimizing through Media Library or using the bulk optimizer.
  • CURL not present warning in Media Settings page.
  • Stability and reliability improvements.
Download this release

Release Info

Developer karim79
Plugin Icon 128x128 Kraken.io Image Optimizer
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4 to 1.0.5

Files changed (3) hide show
  1. kraken.php +31 -20
  2. lib/Kraken.php +5 -1
  3. readme.txt +16 -5
kraken.php CHANGED
@@ -21,8 +21,8 @@
21
  * Plugin URI: http://wordpress.org/plugins/kraken-image-optimizer/
22
  * Description: Optimize Wordpress image uploads through Kraken.io's Image Optimization API
23
  * Author: Karim Salman
24
- * Version: 1.0.4
25
- * Stable Tag: 1.0.4
26
  * Author URI: https://kraken.io
27
  * License GPL2
28
  */
@@ -172,11 +172,6 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
172
 
173
  $result = $this->optimize_image( $image_path, $type );
174
 
175
- if ( $result['success'] == true && !isset( $result['error'] ) ) {
176
- $image_data = wp_get_attachment_metadata( $image_id );
177
- $this->optimize_thumbnails( $image_data );
178
- }
179
-
180
  $kv = array();
181
 
182
  if ( $result['success'] == true && !isset( $result['error'] ) ) {
@@ -317,23 +312,27 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
317
  $error = '';
318
  $valid['api_lossy'] = $input['api_lossy'];
319
 
320
- $status = $this->get_api_status( $input['api_key'], $input['api_secret'] );
 
 
 
321
 
322
- if ( $status !== false ) {
323
 
324
- if ( isset($status['active']) && $status['active'] === true ) {
325
- if ( $status['plan_name'] === 'Developers' ) {
326
- $error = 'Developer API credentials cannot be used with this plugin.';
 
 
 
 
327
  } else {
328
- $valid['api_key'] = $input['api_key'];
329
- $valid['api_secret'] = $input['api_secret'];
330
  }
331
- } else {
332
- $error = 'There is a problem with your credentials. Please check them from your Kraken.io account.';
333
- }
334
 
335
- } else {
336
- $error = 'Please enter a valid Kraken.io API key and secret';
 
337
  }
338
 
339
  if ( !empty( $error) ) {
@@ -464,15 +463,27 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
464
  } else {
465
  $lossy = $settings['api_lossy'] === "lossy";
466
  }
 
 
 
 
 
 
 
 
 
467
  $params = array(
468
- "file" => $image_path,
469
  "wait" => true,
470
  "lossy" => $lossy
471
  );
472
 
473
  $data = $kraken->upload( $params );
 
474
  $data['type'] = !empty( $type ) ? $type : $settings['api_lossy'];
475
 
 
 
476
  return $data;
477
  }
478
 
21
  * Plugin URI: http://wordpress.org/plugins/kraken-image-optimizer/
22
  * Description: Optimize Wordpress image uploads through Kraken.io's Image Optimization API
23
  * Author: Karim Salman
24
+ * Version: 1.0.5
25
+ * Stable Tag: 1.0.5
26
  * Author URI: https://kraken.io
27
  * License GPL2
28
  */
172
 
173
  $result = $this->optimize_image( $image_path, $type );
174
 
 
 
 
 
 
175
  $kv = array();
176
 
177
  if ( $result['success'] == true && !isset( $result['error'] ) ) {
312
  $error = '';
313
  $valid['api_lossy'] = $input['api_lossy'];
314
 
315
+ if ( !function_exists( 'curl_exec' ) ) {
316
+ $error = 'cURL not available. Kraken Image Optimizer requires cURL in order to communicate with Kraken.io servers. <br /> Please ask your system administrator or host to install PHP cURL, or contact support@kraken.io for advice';
317
+ } else {
318
+ $status = $this->get_api_status( $input['api_key'], $input['api_secret'] );
319
 
320
+ if ( $status !== false ) {
321
 
322
+ if ( isset($status['active']) && $status['active'] === true ) {
323
+ if ( $status['plan_name'] === 'Developers' ) {
324
+ $error = 'Developer API credentials cannot be used with this plugin.';
325
+ } else {
326
+ $valid['api_key'] = $input['api_key'];
327
+ $valid['api_secret'] = $input['api_secret'];
328
+ }
329
  } else {
330
+ $error = 'There is a problem with your credentials. Please check them from your Kraken.io account.';
 
331
  }
 
 
 
332
 
333
+ } else {
334
+ $error = 'Please enter a valid Kraken.io API key and secret';
335
+ }
336
  }
337
 
338
  if ( !empty( $error) ) {
463
  } else {
464
  $lossy = $settings['api_lossy'] === "lossy";
465
  }
466
+
467
+ $path_parts = pathinfo( $image_path );
468
+ $tmp_filename = $path_parts['dirname'] . '/' . md5( $path_parts['filename'] );
469
+ if ( !empty( $path_parts['extension'] ) ) {
470
+ $tmp_filename .= '.' . $path_parts['extension'];
471
+ }
472
+
473
+ copy( $image_path, $tmp_filename );
474
+
475
  $params = array(
476
+ "file" => $tmp_filename,
477
  "wait" => true,
478
  "lossy" => $lossy
479
  );
480
 
481
  $data = $kraken->upload( $params );
482
+
483
  $data['type'] = !empty( $type ) ? $type : $settings['api_lossy'];
484
 
485
+ unlink( $tmp_filename );
486
+
487
  return $data;
488
  }
489
 
lib/Kraken.php CHANGED
@@ -48,7 +48,11 @@ class Kraken
48
  );
49
  }
50
 
51
- $file = '@' . $opts['file'];
 
 
 
 
52
 
53
  unset($opts['file']);
54
 
48
  );
49
  }
50
 
51
+ if (function_exists('curl_file_create')) {
52
+ $file = curl_file_create($opts['file'], 'image/jpeg', $opts['file']);
53
+ } else {
54
+ $file = sprintf('@%s', $opts['file']);
55
+ }
56
 
57
  unset($opts['file']);
58
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Kraken Image Optimizer ===
2
  Contributors: karim79
3
- Tags: Image Optimizer, Optimize, Images, Media, Performance, SEO, smushit, compress, kraken-image-optimizer
4
  Requires at least: 3.0.1
5
- Tested up to: 3.9.2
6
  Donate link: https://kraken.io
7
- Stable tag: 1.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
 
@@ -14,7 +14,7 @@ This plugin allows you to optimize all your Wordpress images through the Kraken
14
 
15
  == Description ==
16
 
17
- This plugin allows you to optimize new and existing Wordpress image uploads through [Kraken Image Optimizer's](https://kraken.io "Kraken Image Optimizer") API. Both lossless and lossy optimization modes are supported. Supported filetypes are JPEG, PNG and GIF. Maximum filesize limit is 10MB. For more details, including detailed documentation and plans and pricing, please visit [Kraken.io](https://kraken.io "Kraken Image Optimizer"). **Note: You will need to obtain a paid Kraken API key and secret to use this plugin**.
18
 
19
 
20
 
@@ -25,7 +25,7 @@ This plugin allows you to optimize new and existing Wordpress image uploads thro
25
  * To use this plugin, you must obtain a full API key and secret from [https://kraken.io/plans](https://kraken.io/plans "Kraken Image Optimizer"). The Developer API key/secret will **not** work with this plugin.
26
  * You can use your Kraken API key and secret on as many sites/blogs as you like. We have no per-site license.
27
  * Works great with WPEngine hosted blogs, including the staging area.
28
- * Since version 1.0.4, will work with local WordPress installations, site does not need to be published.
29
 
30
 
31
  Once you have obtained your credentials, from your Wordpress admin, go to the Settings->Media page. The Kraken Wordpress plugin adds a Kraken.io Settings section to the bottom of the page, from where you can enter your API credentials, and select your optimization preferences. Once you have done this, click **Save**. If everything is in order, it will simply say "settings saved" and give you a reassuring green tick in the **Kraken.io settings** section. You can now start optimizing images from within Media Library. Any image you upload from now on, through any of the media upload screens will be optimized on-the-fly by Kraken.
@@ -71,9 +71,20 @@ To test the performance and results of Kraken Image Optimizer, you can try the f
71
 
72
  From our plans page, right [here](https://kraken.io/plans "Kraken.io plans and pricing"). In addition to being able to use our Wordpress Plugin, you can also use the API in your own applications, and take advantage of our [Web Interface PRO ](https://kraken.io/pro "Kraken Web Interface PRO") feature (and much more!) for as little as USD $5 per month.
73
 
 
 
 
 
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
 
77
  = 1.0.4 =
78
  * Utilizes Kraken's upload API instead of URL. Images are uploaded to Kraken.io from WordPress installations, rather than fetched by Kraken.
79
  * Now works will local WordPress installations since hosted images are no longer fetched by URL, but uploaded by the client blog.
1
  === Kraken Image Optimizer ===
2
  Contributors: karim79
3
+ Tags: Image Optimizer, Optimize, Images, Media, Performance, SEO, smushit, smush.it, compress, kraken-image-optimizer, tinypng, jpegmini
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.0.1
6
  Donate link: https://kraken.io
7
+ Stable tag: 1.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
 
14
 
15
  == Description ==
16
 
17
+ This plugin allows you to optimize new and existing Wordpress image uploads through [Kraken Image Optimizer's](https://kraken.io "Kraken Image Optimizer") API. Both lossless and lossy optimization modes are supported. Supported filetypes are JPEG, PNG and GIF. Maximum filesize limit is 16MB. For more details, including detailed documentation and plans and pricing, please visit [Kraken.io](https://kraken.io "Kraken Image Optimizer"). **Note: You will need to obtain a paid Kraken API key and secret to use this plugin**.
18
 
19
 
20
 
25
  * To use this plugin, you must obtain a full API key and secret from [https://kraken.io/plans](https://kraken.io/plans "Kraken Image Optimizer"). The Developer API key/secret will **not** work with this plugin.
26
  * You can use your Kraken API key and secret on as many sites/blogs as you like. We have no per-site license.
27
  * Works great with WPEngine hosted blogs, including the staging area.
28
+ * Since version 1.0.4, the plugin will work with local WordPress installations; the client site does not need to be published on the web.
29
 
30
 
31
  Once you have obtained your credentials, from your Wordpress admin, go to the Settings->Media page. The Kraken Wordpress plugin adds a Kraken.io Settings section to the bottom of the page, from where you can enter your API credentials, and select your optimization preferences. Once you have done this, click **Save**. If everything is in order, it will simply say "settings saved" and give you a reassuring green tick in the **Kraken.io settings** section. You can now start optimizing images from within Media Library. Any image you upload from now on, through any of the media upload screens will be optimized on-the-fly by Kraken.
71
 
72
  From our plans page, right [here](https://kraken.io/plans "Kraken.io plans and pricing"). In addition to being able to use our Wordpress Plugin, you can also use the API in your own applications, and take advantage of our [Web Interface PRO ](https://kraken.io/pro "Kraken Web Interface PRO") feature (and much more!) for as little as USD $5 per month.
73
 
74
+ = Will the optimized images remain on my blog if I uninstall the plugin? =
75
+
76
+ Yes, of course they will. Our plugin simply replaces the image files on your blog with the ones optimized by us.
77
+
78
 
79
  == Changelog ==
80
 
81
+ = 1.0.5 =
82
+ * Fixed CURL issues related to latest PHP versions.
83
+ * Can now optimize filenames with non-Latin alphabet (such as Germanic umlauts, Cyrillic alphabet, etc).
84
+ * Performance improvement when optimizing through Media Library or using the bulk optimizer.
85
+ * CURL not present warning in Media Settings page.
86
+ * Stability and reliability improvements.
87
+
88
  = 1.0.4 =
89
  * Utilizes Kraken's upload API instead of URL. Images are uploaded to Kraken.io from WordPress installations, rather than fetched by Kraken.
90
  * Now works will local WordPress installations since hosted images are no longer fetched by URL, but uploaded by the client blog.