Version Description
- Added support for WP Retina 2x
Download this release
Release Info
Developer | keycdn |
Plugin | Optimus – WordPress Image Optimizer |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.5 to 1.4.6
- inc/optimus.class.php +13 -1
- inc/optimus_request.class.php +100 -2
- optimus.php +1 -1
- readme.txt +6 -11
inc/optimus.class.php
CHANGED
@@ -32,7 +32,7 @@ class Optimus
|
|
32 |
* Konstruktor der Klasse
|
33 |
*
|
34 |
* @since 0.0.1
|
35 |
-
* @change 1.4.
|
36 |
*/
|
37 |
|
38 |
public function __construct()
|
@@ -54,6 +54,7 @@ class Optimus
|
|
54 |
);
|
55 |
}
|
56 |
|
|
|
57 |
add_filter(
|
58 |
'wp_delete_file',
|
59 |
array(
|
@@ -62,6 +63,17 @@ class Optimus
|
|
62 |
)
|
63 |
);
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/* Filter */
|
66 |
if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) OR (defined('DOING_CRON') && DOING_CRON) OR (defined('DOING_AJAX') && DOING_AJAX) OR (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) ) {
|
67 |
return;
|
32 |
* Konstruktor der Klasse
|
33 |
*
|
34 |
* @since 0.0.1
|
35 |
+
* @change 1.4.6
|
36 |
*/
|
37 |
|
38 |
public function __construct()
|
54 |
);
|
55 |
}
|
56 |
|
57 |
+
/* Remove converted files */
|
58 |
add_filter(
|
59 |
'wp_delete_file',
|
60 |
array(
|
63 |
)
|
64 |
);
|
65 |
|
66 |
+
/* WP Retina 2x compatibility (existing images) */
|
67 |
+
add_action(
|
68 |
+
'wr2x_retina_file_added',
|
69 |
+
array(
|
70 |
+
'Optimus_Request',
|
71 |
+
'optimize_wr2x_image'
|
72 |
+
),
|
73 |
+
10,
|
74 |
+
2
|
75 |
+
);
|
76 |
+
|
77 |
/* Filter */
|
78 |
if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) OR (defined('DOING_CRON') && DOING_CRON) OR (defined('DOING_AJAX') && DOING_AJAX) OR (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) ) {
|
79 |
return;
|
inc/optimus_request.class.php
CHANGED
@@ -9,7 +9,6 @@ defined('ABSPATH') OR exit;
|
|
9 |
* Optimus_Request
|
10 |
*
|
11 |
* @since 1.1.7
|
12 |
-
* @change 1.4.0
|
13 |
*/
|
14 |
|
15 |
class Optimus_Request
|
@@ -83,6 +82,67 @@ class Optimus_Request
|
|
83 |
exit;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
/**
|
88 |
* Build optimization for a upload image including previews
|
@@ -231,6 +291,22 @@ class Optimus_Request
|
|
231 |
)
|
232 |
);
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
/* Evaluate response */
|
235 |
if ( is_numeric($action_response) ) {
|
236 |
$response_filesize = $action_response;
|
@@ -249,6 +325,17 @@ class Optimus_Request
|
|
249 |
'webp' => true
|
250 |
)
|
251 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
|
254 |
/* File size difference */
|
@@ -543,7 +630,7 @@ class Optimus_Request
|
|
543 |
* Löscht erzeugte WebP-Dateien
|
544 |
*
|
545 |
* @since 1.1.4
|
546 |
-
* @change 1.
|
547 |
*
|
548 |
* @param string $file Zu löschende Original-Datei
|
549 |
* @return string $file Zu löschende Original-Datei
|
@@ -570,6 +657,17 @@ class Optimus_Request
|
|
570 |
$converted_file = path_join($base_dir, $converted_file);
|
571 |
}
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
/* Replace to webp extension */
|
574 |
$converted_file = self::_replace_file_extension(
|
575 |
$converted_file,
|
9 |
* Optimus_Request
|
10 |
*
|
11 |
* @since 1.1.7
|
|
|
12 |
*/
|
13 |
|
14 |
class Optimus_Request
|
82 |
exit;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Image optimization for wp retina 2x
|
87 |
+
*
|
88 |
+
* @since 1.4.6
|
89 |
+
* @change 1.4.6
|
90 |
+
*
|
91 |
+
* @param integer $attachment_id Attachment ID
|
92 |
+
* @param string $upload_path_file_retina Retina file path
|
93 |
+
*/
|
94 |
+
|
95 |
+
public static function optimize_wr2x_image($attachment_id, $upload_path_file_retina) {
|
96 |
+
// get file size
|
97 |
+
$upload_filesize = (int)filesize($upload_path_file_retina);
|
98 |
+
|
99 |
+
/* Get the attachment */
|
100 |
+
$attachment = get_post($attachment_id);
|
101 |
+
|
102 |
+
// get mime type
|
103 |
+
$mime_type = get_post_mime_type($attachment);
|
104 |
+
|
105 |
+
// check mime type and size
|
106 |
+
if ( self::_allowed_mime_type($mime_type) && self::_allowed_file_size($mime_type, $upload_filesize) ) {
|
107 |
+
// get optimus plugin options
|
108 |
+
$options = Optimus::get_options();
|
109 |
+
|
110 |
+
// set cURL options
|
111 |
+
add_action(
|
112 |
+
'http_api_curl',
|
113 |
+
array(
|
114 |
+
__CLASS__,
|
115 |
+
'set_curl_options'
|
116 |
+
)
|
117 |
+
);
|
118 |
+
|
119 |
+
// set https scheme
|
120 |
+
if ( $options['secure_transport'] && Optimus_HQ::is_unlocked() ) {
|
121 |
+
self::$_remote_scheme = 'https';
|
122 |
+
}
|
123 |
+
|
124 |
+
// request: optimize retina image
|
125 |
+
self::_do_image_action(
|
126 |
+
$upload_path_file_retina,
|
127 |
+
array(
|
128 |
+
'file' => null,
|
129 |
+
'copy' => $options['copy_markers']
|
130 |
+
)
|
131 |
+
);
|
132 |
+
|
133 |
+
// request: webp convert
|
134 |
+
if ( $options['webp_convert'] && Optimus_HQ::is_unlocked() ) {
|
135 |
+
self::_do_image_action(
|
136 |
+
$upload_path_file_retina,
|
137 |
+
array(
|
138 |
+
'file' => null,
|
139 |
+
'webp' => true
|
140 |
+
)
|
141 |
+
);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
|
147 |
/**
|
148 |
* Build optimization for a upload image including previews
|
291 |
)
|
292 |
);
|
293 |
|
294 |
+
/* get retina image [WP Retina 2x] */
|
295 |
+
if ( function_exists( 'wr2x_get_retina' ) ) {
|
296 |
+
$upload_path_file_retina = wr2x_get_retina( $upload_path_file );
|
297 |
+
}
|
298 |
+
|
299 |
+
/* Request: Optimize retina image [WP Retina 2x] */
|
300 |
+
if ( $upload_path_file_retina ) {
|
301 |
+
self::_do_image_action(
|
302 |
+
$upload_path_file_retina,
|
303 |
+
array(
|
304 |
+
'file' => $upload_url_file_encoded,
|
305 |
+
'copy' => $options['copy_markers']
|
306 |
+
)
|
307 |
+
);
|
308 |
+
}
|
309 |
+
|
310 |
/* Evaluate response */
|
311 |
if ( is_numeric($action_response) ) {
|
312 |
$response_filesize = $action_response;
|
325 |
'webp' => true
|
326 |
)
|
327 |
);
|
328 |
+
|
329 |
+
/* convert retina image to webp [WP Retina 2x] */
|
330 |
+
if ( $upload_path_file_retina ) {
|
331 |
+
self::_do_image_action(
|
332 |
+
$upload_path_file_retina,
|
333 |
+
array(
|
334 |
+
'file' => $upload_url_file_encoded,
|
335 |
+
'webp' => true
|
336 |
+
)
|
337 |
+
);
|
338 |
+
}
|
339 |
}
|
340 |
|
341 |
/* File size difference */
|
630 |
* Löscht erzeugte WebP-Dateien
|
631 |
*
|
632 |
* @since 1.1.4
|
633 |
+
* @change 1.4.6
|
634 |
*
|
635 |
* @param string $file Zu löschende Original-Datei
|
636 |
* @return string $file Zu löschende Original-Datei
|
657 |
$converted_file = path_join($base_dir, $converted_file);
|
658 |
}
|
659 |
|
660 |
+
/* Remove retina image if exists [WP Retina 2x] */
|
661 |
+
$converted_file_retina = substr_replace(
|
662 |
+
$converted_file,
|
663 |
+
'@2x.webp',
|
664 |
+
(strlen(pathinfo($file, PATHINFO_EXTENSION)) * -1 - 1)
|
665 |
+
);
|
666 |
+
|
667 |
+
if ( file_exists($converted_file_retina) ) {
|
668 |
+
@unlink($converted_file_retina);
|
669 |
+
}
|
670 |
+
|
671 |
/* Replace to webp extension */
|
672 |
$converted_file = self::_replace_file_extension(
|
673 |
$converted_file,
|
optimus.php
CHANGED
@@ -7,7 +7,7 @@ Author: KeyCDN
|
|
7 |
Author URI: https://www.keycdn.com
|
8 |
Plugin URI: https://optimus.io
|
9 |
License: GPLv2 or later
|
10 |
-
Version: 1.4.
|
11 |
*/
|
12 |
|
13 |
/*
|
7 |
Author URI: https://www.keycdn.com
|
8 |
Plugin URI: https://optimus.io
|
9 |
License: GPLv2 or later
|
10 |
+
Version: 1.4.6
|
11 |
*/
|
12 |
|
13 |
/*
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: keycdn
|
3 |
Tags: images, optimize, compress, progressive, performance, png, jpeg, webp, image optimizer, wordpress image optimizer, optimize image, optimize jpg, optimize jpeg, optimize png, compress image, progressive jpeg, progressive jpg
|
4 |
Requires at least: 3.8
|
5 |
-
Tested up to: 4.
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -32,7 +32,7 @@ During the uploading process of images to the media library, the *Optimus* plugi
|
|
32 |
|
33 |
The optimization of images - *including thumbnails* - is conducted in the background and outside of the view of the user. The image compression gains per file are displayed by Optimus within the media library in form of a percentage value, see [screenshot](https://wordpress.org/plugins/optimus/screenshots/).
|
34 |
|
35 |
-
Differently from common optimization tools, this WordPress image optimization
|
36 |
|
37 |
Optimus supports the conversion of images to the new [*WebP* image format](https://www.keycdn.com/blog/convert-to-webp-the-successor-of-jpeg/).
|
38 |
|
@@ -53,6 +53,7 @@ Optimus supports the conversion of images to the new [*WebP* image format](https
|
|
53 |
* Support for WooCommerce
|
54 |
* WordPress multisite-support
|
55 |
* [Bulk optimization](https://optimus.io/support/image-bulk-optimization/) (optimize existing images)
|
|
|
56 |
|
57 |
|
58 |
= Privacy =
|
@@ -65,13 +66,6 @@ Optimus supports the conversion of images to the new [*WebP* image format](https
|
|
65 |
* Your images have been optimized using Desktop tools such as ImageOptim (Mac) or PNGGauntlet (Win) before you upload them? Optimus has the significant benefit of also minimizing the thumbnails (=preview images) created by WordPress. After all, themes almost always integrate thumbnails rather than original images.
|
66 |
|
67 |
|
68 |
-
= Translations =
|
69 |
-
* English (default)
|
70 |
-
* German
|
71 |
-
|
72 |
-
*Note:* Optimus is localized. Please contribute your language to the plugin to make it even more awesome.
|
73 |
-
|
74 |
-
|
75 |
= System Requirements =
|
76 |
* PHP >=5.2.4
|
77 |
* WordPress >=3.8
|
@@ -88,14 +82,15 @@ Optimus supports the conversion of images to the new [*WebP* image format](https
|
|
88 |
|
89 |
|
90 |
= Author =
|
91 |
-
* [Twitter](https://twitter.com/keycdn)
|
92 |
-
* [Google+](https://plus.google.com/+Keycdn "Google+")
|
93 |
* [KeyCDN](https://www.keycdn.com "KeyCDN")
|
94 |
|
95 |
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
99 |
= 1.4.5 =
|
100 |
* Optimization to avoid conflicts with other plugins or themes
|
101 |
|
2 |
Contributors: keycdn
|
3 |
Tags: images, optimize, compress, progressive, performance, png, jpeg, webp, image optimizer, wordpress image optimizer, optimize image, optimize jpg, optimize jpeg, optimize png, compress image, progressive jpeg, progressive jpg
|
4 |
Requires at least: 3.8
|
5 |
+
Tested up to: 4.5
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
32 |
|
33 |
The optimization of images - *including thumbnails* - is conducted in the background and outside of the view of the user. The image compression gains per file are displayed by Optimus within the media library in form of a percentage value, see [screenshot](https://wordpress.org/plugins/optimus/screenshots/).
|
34 |
|
35 |
+
Differently from common optimization tools, this WordPress image optimization plugin never alters the quality of images. Instead, superfluous information that is saved by image processing programs and is not even necessary for displaying the image is extracted from image files. This way, the quality of the graphics remains intact while the image size can be reduced significantly. If you wish, Optimus keeps all author, EXIF and copyright information contained within the photos — the compressional gains will be correspondingly lower.
|
36 |
|
37 |
Optimus supports the conversion of images to the new [*WebP* image format](https://www.keycdn.com/blog/convert-to-webp-the-successor-of-jpeg/).
|
38 |
|
53 |
* Support for WooCommerce
|
54 |
* WordPress multisite-support
|
55 |
* [Bulk optimization](https://optimus.io/support/image-bulk-optimization/) (optimize existing images)
|
56 |
+
* Optimize images generated by [WP Retina 2x](https://wordpress.org/plugins/wp-retina-2x/) (incl. conversion to WebP)
|
57 |
|
58 |
|
59 |
= Privacy =
|
66 |
* Your images have been optimized using Desktop tools such as ImageOptim (Mac) or PNGGauntlet (Win) before you upload them? Optimus has the significant benefit of also minimizing the thumbnails (=preview images) created by WordPress. After all, themes almost always integrate thumbnails rather than original images.
|
67 |
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
= System Requirements =
|
70 |
* PHP >=5.2.4
|
71 |
* WordPress >=3.8
|
82 |
|
83 |
|
84 |
= Author =
|
|
|
|
|
85 |
* [KeyCDN](https://www.keycdn.com "KeyCDN")
|
86 |
|
87 |
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
= 1.4.6 =
|
92 |
+
* Added support for WP Retina 2x
|
93 |
+
|
94 |
= 1.4.5 =
|
95 |
* Optimization to avoid conflicts with other plugins or themes
|
96 |
|