Version Description
- Utilizes Kraken's upload API instead of URL. Images are uploaded to Kraken.io from WordPress installations, rather than fetched by Kraken.
- Now works will local WordPress installations since hosted images are no longer fetched by URL, but uploaded by the client blog.
Download this release
Release Info
Developer | karim79 |
Plugin | Kraken.io Image Optimizer |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.3.4 to 1.0.4
- kraken.php +8 -31
- lib/Kraken.php +1 -1
- readme.txt +6 -1
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.
|
25 |
-
* Stable Tag: 1.0.
|
26 |
* Author URI: https://kraken.io
|
27 |
* License GPL2
|
28 |
*/
|
@@ -149,13 +149,6 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
149 |
|
150 |
if ( wp_attachment_is_image( $image_id ) ) {
|
151 |
|
152 |
-
$imageUrl = wp_get_attachment_url( $image_id );
|
153 |
-
|
154 |
-
// fix for blogs with nasty plugins which convert URLs to relative paths
|
155 |
-
if ( filter_var( $imageUrl, FILTER_VALIDATE_URL ) === false ) {
|
156 |
-
$imageUrl = get_site_url() . $imageUrl;
|
157 |
-
}
|
158 |
-
|
159 |
$image_path = get_attached_file( $image_id );
|
160 |
$settings = $this->kraken_settings;
|
161 |
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
@@ -177,7 +170,7 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
177 |
die();
|
178 |
}
|
179 |
|
180 |
-
$result = $this->optimize_image( $
|
181 |
|
182 |
if ( $result['success'] == true && !isset( $result['error'] ) ) {
|
183 |
$image_data = wp_get_attachment_metadata( $image_id );
|
@@ -253,14 +246,8 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
253 |
|
254 |
$settings = $this->kraken_settings;
|
255 |
$type = $settings['api_lossy'];
|
256 |
-
$imageUrl = wp_get_attachment_url( $image_id );
|
257 |
-
|
258 |
-
if ( filter_var( $imageUrl, FILTER_VALIDATE_URL ) === false ) {
|
259 |
-
$imageUrl = get_site_url() . $imageUrl;
|
260 |
-
}
|
261 |
-
|
262 |
$image_path = get_attached_file( $image_id );
|
263 |
-
$result = $this->optimize_image( $
|
264 |
|
265 |
if ( $result['success'] == true && !isset( $result['error'] ) ) {
|
266 |
|
@@ -468,7 +455,7 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
468 |
return $rv !== false;
|
469 |
}
|
470 |
|
471 |
-
function optimize_image( $
|
472 |
$settings = $this->kraken_settings;
|
473 |
$kraken = new Kraken( $settings['api_key'], $settings['api_secret'] );
|
474 |
|
@@ -478,12 +465,12 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
478 |
$lossy = $settings['api_lossy'] === "lossy";
|
479 |
}
|
480 |
$params = array(
|
481 |
-
"
|
482 |
"wait" => true,
|
483 |
"lossy" => $lossy
|
484 |
);
|
485 |
|
486 |
-
$data = $kraken->
|
487 |
$data['type'] = !empty( $type ) ? $type : $settings['api_lossy'];
|
488 |
|
489 |
return $data;
|
@@ -509,14 +496,6 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
509 |
$upload_base_path = $upload_dir['basedir'];
|
510 |
$upload_full_path = $upload_base_path . '/' . $upload_subdir;
|
511 |
|
512 |
-
// all the way up to /uploads
|
513 |
-
$upload_base_url = $upload_dir['baseurl'];
|
514 |
-
$upload_url = $upload_base_url . '/' . $upload_subdir;
|
515 |
-
|
516 |
-
if ( filter_var( $upload_url, FILTER_VALIDATE_URL ) === false ) {
|
517 |
-
$upload_url = get_site_url() . $upload_url;
|
518 |
-
}
|
519 |
-
|
520 |
$sizes = array();
|
521 |
|
522 |
if ( isset( $image_data['sizes'] ) ) {
|
@@ -525,7 +504,6 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
525 |
|
526 |
if ( !empty( $sizes ) ) {
|
527 |
|
528 |
-
$thumb_url = '';
|
529 |
$thumb_path = '';
|
530 |
|
531 |
$thumbs_optimized_store = array();
|
@@ -534,11 +512,10 @@ if ( !class_exists( 'Wp_Kraken' ) ) {
|
|
534 |
foreach ( $sizes as $key => $size ) {
|
535 |
|
536 |
$thumb_path = $upload_full_path . '/' . $size['file'];
|
537 |
-
$thumb_url = $upload_url . '/' . $size['file'];
|
538 |
|
539 |
if ( file_exists( $thumb_path ) !== false ) {
|
540 |
|
541 |
-
$result = $this->optimize_image( $
|
542 |
|
543 |
if ( !empty($result) && isset($result['success']) && isset( $result['kraked_url'] ) ) {
|
544 |
$kraked_url = $result["kraked_url"];
|
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 |
*/
|
149 |
|
150 |
if ( wp_attachment_is_image( $image_id ) ) {
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
$image_path = get_attached_file( $image_id );
|
153 |
$settings = $this->kraken_settings;
|
154 |
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
170 |
die();
|
171 |
}
|
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 );
|
246 |
|
247 |
$settings = $this->kraken_settings;
|
248 |
$type = $settings['api_lossy'];
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
$image_path = get_attached_file( $image_id );
|
250 |
+
$result = $this->optimize_image( $image_path, $type );
|
251 |
|
252 |
if ( $result['success'] == true && !isset( $result['error'] ) ) {
|
253 |
|
455 |
return $rv !== false;
|
456 |
}
|
457 |
|
458 |
+
function optimize_image( $image_path, $type ) {
|
459 |
$settings = $this->kraken_settings;
|
460 |
$kraken = new Kraken( $settings['api_key'], $settings['api_secret'] );
|
461 |
|
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;
|
496 |
$upload_base_path = $upload_dir['basedir'];
|
497 |
$upload_full_path = $upload_base_path . '/' . $upload_subdir;
|
498 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
$sizes = array();
|
500 |
|
501 |
if ( isset( $image_data['sizes'] ) ) {
|
504 |
|
505 |
if ( !empty( $sizes ) ) {
|
506 |
|
|
|
507 |
$thumb_path = '';
|
508 |
|
509 |
$thumbs_optimized_store = array();
|
512 |
foreach ( $sizes as $key => $size ) {
|
513 |
|
514 |
$thumb_path = $upload_full_path . '/' . $size['file'];
|
|
|
515 |
|
516 |
if ( file_exists( $thumb_path ) !== false ) {
|
517 |
|
518 |
+
$result = $this->optimize_image( $thumb_path, $this->optimization_type );
|
519 |
|
520 |
if ( !empty($result) && isset($result['success']) && isset( $result['kraked_url'] ) ) {
|
521 |
$kraked_url = $result["kraked_url"];
|
lib/Kraken.php
CHANGED
@@ -18,7 +18,7 @@ class Kraken
|
|
18 |
public function url($opts = array())
|
19 |
{
|
20 |
$data = json_encode(array_merge($this->auth, $opts));
|
21 |
-
$response = self::request($data, "https://api
|
22 |
|
23 |
return $response;
|
24 |
}
|
18 |
public function url($opts = array())
|
19 |
{
|
20 |
$data = json_encode(array_merge($this->auth, $opts));
|
21 |
+
$response = self::request($data, "https://api.kraken.io/v1/url");
|
22 |
|
23 |
return $response;
|
24 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Image Optimizer, Optimize, Images, Media, Performance, SEO, smushit, compr
|
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
|
@@ -25,6 +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 |
|
29 |
|
30 |
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.
|
@@ -73,6 +74,10 @@ From our plans page, right [here](https://kraken.io/plans "Kraken.io plans and p
|
|
73 |
|
74 |
== Changelog ==
|
75 |
|
|
|
|
|
|
|
|
|
76 |
= 1.0.3.4 =
|
77 |
* Performance improvements.
|
78 |
|
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 |
|
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.
|
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.
|
80 |
+
|
81 |
= 1.0.3.4 =
|
82 |
* Performance improvements.
|
83 |
|