Version Description
Unfortunately this plugin is no longer maintained, at least not by me. See the plugin page for all the details. Thanks for all the smushing fun!
=
Download this release
Release Info
Developer | alexdunae |
Plugin | Smush Image Compression and Optimization |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.5.0 to 1.6.1
- readme.txt +38 -14
- settings.php +47 -0
- wp-smushit.php +23 -22
readme.txt
CHANGED
@@ -1,19 +1,33 @@
|
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
-
Version: 1.
|
4 |
Author: Dialect
|
5 |
Author URI: http://dialect.ca/?wp_smush_it
|
6 |
Contributors: alexdunae
|
7 |
Tags: images, image, attachments, attachment
|
8 |
Requires at least: 2.9
|
9 |
-
Tested up to: 3.2
|
10 |
-
Stable tag: 1.
|
11 |
Donate link: http://dunae.ca/donate.html
|
12 |
|
13 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
14 |
|
15 |
== Description ==
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
Yahoo's excellent <a href="http://developer.yahoo.com/performance/">Exceptional Performance series</a> recommends <a href="http://developer.yahoo.com/performance/rules.html#opt_images">optimizing images</a> in several lossless ways:
|
18 |
|
19 |
* stripping meta data from JPEGs
|
@@ -31,20 +45,16 @@ You can also run your existing images through Smush.it via the WordPress `Media
|
|
31 |
|
32 |
As of version 1.4.0 there is a new, experimental `Bulk Smush.it` feature. You can find the link under the `Media Library` tab.
|
33 |
|
|
|
|
|
|
|
|
|
34 |
= NextGEN Gallery =
|
35 |
NextGEN user? Also download the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">WP Smush.it NextGEN Integration</a> plugin.
|
36 |
|
37 |
-
= Privacy =
|
38 |
Be sure you’re comfortable with Smush.it’s privacy policy (found on their <a href="http://info.yahoo.com/legal/us/yahoo/smush_it/smush_it-4378.html">FAQ</a>).
|
39 |
|
40 |
-
= Donate? =
|
41 |
-
|
42 |
-
If you're so inclined, I've setup <a href="http://dunae.ca/donate.html">a donation page</a>.
|
43 |
-
|
44 |
-
= Updates, etc... =
|
45 |
-
|
46 |
-
Plugin updates are announced on [http://www.twitter.com/TheCHANGELOG](http://www.twitter.com/TheCHANGELOG).
|
47 |
-
|
48 |
== Screenshots ==
|
49 |
|
50 |
1. See the savings from Smush.it in the Media Library.
|
@@ -53,10 +63,24 @@ Plugin updates are announced on [http://www.twitter.com/TheCHANGELOG](http://www
|
|
53 |
|
54 |
1. Upload the `wp-smushit` plugin to your `/wp-content/plugins/` directory.
|
55 |
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
|
|
56 |
1. Done!
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 1.5.0 =
|
61 |
* added basic integration for the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">NextGEN gallery plugin</a>
|
62 |
* add support for media bulk action dropdown
|
@@ -89,10 +113,10 @@ Plugin updates are announced on [http://www.twitter.com/TheCHANGELOG](http://www
|
|
89 |
* handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
|
90 |
* avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
|
91 |
|
92 |
-
= 1.2.10 =
|
93 |
* removed testing link
|
94 |
|
95 |
-
= 1.2.9 =
|
96 |
* updated Smush.it endpoint URL
|
97 |
|
98 |
= 1.2.8 =
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
+
Version: 1.6.1
|
4 |
Author: Dialect
|
5 |
Author URI: http://dialect.ca/?wp_smush_it
|
6 |
Contributors: alexdunae
|
7 |
Tags: images, image, attachments, attachment
|
8 |
Requires at least: 2.9
|
9 |
+
Tested up to: 3.3.2
|
10 |
+
Stable tag: 1.6.1
|
11 |
Donate link: http://dunae.ca/donate.html
|
12 |
|
13 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
14 |
|
15 |
== Description ==
|
16 |
|
17 |
+
= WP SMUSH.IT IS NO LONGER MAINTAINED =
|
18 |
+
|
19 |
+
Unfortunately this plugin is no longer maintained, at least not by me. Growing family and work as well as shifting focus just don't leave me the time.
|
20 |
+
|
21 |
+
(The plugin still works, though there is the occassional glitch.)
|
22 |
+
|
23 |
+
If anyone out there is interested in taking the plugin over, feel free to get in touch at <a href="mailto:code@dialect.ca">code@dialect.ca</a>. The most obivious way forward is to add support for <tt>pngcrush</tt>, <tt>optipng</tt>, etc... on servers that support, and even look at what can be done within GD.
|
24 |
+
|
25 |
+
Somewhat related, to this day it's not clear what Yahoo intends to do with their Smush.it system. Users of the plugin have always gotten unofficial permission to use the service, but there's no way of knowing how long that will last (though it has been years).
|
26 |
+
|
27 |
+
I'd love to do be able to do more with WP Smush.it, but life conspires against it. It's been fun smushing the hell out of those extra bytes with you all.
|
28 |
+
|
29 |
+
= Original Description =
|
30 |
+
|
31 |
Yahoo's excellent <a href="http://developer.yahoo.com/performance/">Exceptional Performance series</a> recommends <a href="http://developer.yahoo.com/performance/rules.html#opt_images">optimizing images</a> in several lossless ways:
|
32 |
|
33 |
* stripping meta data from JPEGs
|
45 |
|
46 |
As of version 1.4.0 there is a new, experimental `Bulk Smush.it` feature. You can find the link under the `Media Library` tab.
|
47 |
|
48 |
+
= Errors =
|
49 |
+
|
50 |
+
Sometimes the Smush.it service goes down or is under heavy load. If the plugin has difficulty connecting to Smush.it then automatically smushing is temporarily disabled (currently for 6 hours). You can always re-enable it via the `Media > Settings` screen or manually smush the image from the Media Library.
|
51 |
+
|
52 |
= NextGEN Gallery =
|
53 |
NextGEN user? Also download the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">WP Smush.it NextGEN Integration</a> plugin.
|
54 |
|
55 |
+
= Privacy =
|
56 |
Be sure you’re comfortable with Smush.it’s privacy policy (found on their <a href="http://info.yahoo.com/legal/us/yahoo/smush_it/smush_it-4378.html">FAQ</a>).
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
== Screenshots ==
|
59 |
|
60 |
1. See the savings from Smush.it in the Media Library.
|
63 |
|
64 |
1. Upload the `wp-smushit` plugin to your `/wp-content/plugins/` directory.
|
65 |
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
66 |
+
1. Automatic smushing of uploaded images can be controlled on the `Settings > Media` screen
|
67 |
1. Done!
|
68 |
|
69 |
+
== Upgrade Notice ==
|
70 |
+
|
71 |
+
= 1.6.1 =
|
72 |
+
|
73 |
+
Unfortunately this plugin is no longer maintained, at least not by me. See <a href="http://wordpress.org/extend/plugins/wp-smushit/">the plugin page</a> for all the details. Thanks for all the smushing fun!
|
74 |
+
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 1.6.1 =
|
78 |
+
* no longer maintained notice
|
79 |
+
|
80 |
+
= 1.6.0 =
|
81 |
+
* added setting to disable automatic smushing on upload (default is true)
|
82 |
+
* on HTTP error, smushing will be temporarily disabled for 6 hours
|
83 |
+
|
84 |
= 1.5.0 =
|
85 |
* added basic integration for the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">NextGEN gallery plugin</a>
|
86 |
* add support for media bulk action dropdown
|
113 |
* handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
|
114 |
* avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
|
115 |
|
116 |
+
= 1.2.10 =
|
117 |
* removed testing link
|
118 |
|
119 |
+
= 1.2.9 =
|
120 |
* updated Smush.it endpoint URL
|
121 |
|
122 |
= 1.2.8 =
|
settings.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
|
5 |
+
Each service has a setting specifying whether it should be used automatically on upload.
|
6 |
+
|
7 |
+
Values are:
|
8 |
+
-1 Don't use (until manually enabled via Media > Settings)
|
9 |
+
0 Use automatically
|
10 |
+
n Any other number is a Unix timestamp indicating when the service can be used again
|
11 |
+
|
12 |
+
*/
|
13 |
+
|
14 |
+
define('WP_SMUSHIT_AUTO_OK', 0);
|
15 |
+
define('WP_SMUSHIT_AUTO_NEVER', -1);
|
16 |
+
|
17 |
+
|
18 |
+
function wp_smushit_register_settings() {
|
19 |
+
add_settings_section( 'wp_smushit_settings', 'WP Smush.it', 'wp_smushit_settings_cb', 'media' );
|
20 |
+
add_settings_field( 'wp_smushit_smushit_auto', 'Use Smush.it on upload?', 'wp_smushit_smushit_auto_cb', 'media', 'wp_smushit_settings' );
|
21 |
+
register_setting( 'media', 'wp_smushit_smushit_auto');
|
22 |
+
}
|
23 |
+
add_action('admin_init', 'wp_smushit_register_settings');
|
24 |
+
|
25 |
+
function wp_smushit_settings_cb() {
|
26 |
+
}
|
27 |
+
|
28 |
+
function wp_smushit_smushit_auto_cb() {
|
29 |
+
wp_smushit_render_auto_opts( 'wp_smushit_smushit_auto' );
|
30 |
+
}
|
31 |
+
|
32 |
+
function wp_smushit_render_auto_opts( $key ) {
|
33 |
+
$val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) );
|
34 |
+
printf( "<select name='%1\$s' id='%1\$s'>", esc_attr( $key ) );
|
35 |
+
echo '<option value=' . WP_SMUSHIT_AUTO_OK . ' ' . selected( WP_SMUSHIT_AUTO_OK, $val ) . '>Automatically process on upload</option>';
|
36 |
+
echo '<option value=' . WP_SMUSHIT_AUTO_NEVER . ' ' . selected( WP_SMUSHIT_AUTO_NEVER, $val ) . '>Do not process on upload</option>';
|
37 |
+
|
38 |
+
if ( $val > 0 ) {
|
39 |
+
printf( '<option value="%d" selected="selected">Temporarily disabled until %s</option>', $val, date( 'M j, Y \a\t H:i', $val ) );
|
40 |
+
}
|
41 |
+
echo '</select>';
|
42 |
+
}
|
43 |
+
|
44 |
+
// default is 6hrs
|
45 |
+
function wp_smushit_temporarily_disable( $seconds = 21600) {
|
46 |
+
update_option( 'wp_smushit_smushit_auto', time() + $seconds );
|
47 |
+
}
|
wp-smushit.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Smush.it
|
|
4 |
Plugin URI: http://dialect.ca/code/wp-smushit/
|
5 |
Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
6 |
Author: Dialect
|
7 |
-
Version: 1.
|
8 |
Author URI: http://dialect.ca/
|
9 |
*/
|
10 |
|
@@ -23,14 +23,19 @@ define('SMUSHIT_REQ_URL', 'http://www.smushit.com/ysmush.it/ws.php?img=%s');
|
|
23 |
define('SMUSHIT_BASE_URL', 'http://www.smushit.com/');
|
24 |
|
25 |
define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
|
26 |
-
define('WP_SMUSHIT_UA', 'WP Smush.it/1.
|
27 |
define('WP_SMUSHIT_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
|
28 |
|
|
|
|
|
29 |
|
30 |
/**
|
31 |
* Hooks
|
32 |
*/
|
33 |
-
|
|
|
|
|
|
|
34 |
add_filter('manage_media_columns', 'wp_smushit_columns');
|
35 |
add_action('manage_media_custom_column', 'wp_smushit_custom_column', 10, 2);
|
36 |
add_action('admin_init', 'wp_smushit_admin_init');
|
@@ -49,6 +54,7 @@ function wp_smushit_admin_menu() {
|
|
49 |
}
|
50 |
add_action( 'admin_menu', 'wp_smushit_admin_menu' );
|
51 |
|
|
|
52 |
function wp_smushit_bulk_preview() {
|
53 |
if ( function_exists( 'apache_setenv' ) ) {
|
54 |
@apache_setenv('no-gzip', 1);
|
@@ -233,6 +239,10 @@ function wp_smushit_should_resmush($previous_status) {
|
|
233 |
* Called after `wp_generate_attachment_metadata` is completed.
|
234 |
*/
|
235 |
function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = true) {
|
|
|
|
|
|
|
|
|
236 |
$file_path = $meta['file'];
|
237 |
$store_absolute_path = true;
|
238 |
$upload_dir = wp_upload_dir();
|
@@ -243,9 +253,6 @@ function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = tr
|
|
243 |
$store_absolute_path = false;
|
244 |
$file_path = $upload_path . $file_path;
|
245 |
}
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
|
250 |
if ( $force_resmush || wp_smushit_should_resmush( @$meta['wp_smushit'] ) ) {
|
251 |
list($file, $msg) = wp_smushit($file_path);
|
@@ -288,15 +295,15 @@ function wp_smushit_post($file_url) {
|
|
288 |
$data = false;
|
289 |
|
290 |
if ( function_exists('wp_remote_get') ) {
|
291 |
-
|
292 |
-
$response = wp_remote_get($req, array('user-agent' => WP_SMUSHIT_UA));
|
293 |
|
294 |
if( is_wp_error( $response ) ) {
|
295 |
-
|
|
|
|
|
296 |
}
|
297 |
|
298 |
$data = wp_remote_retrieve_body($response);
|
299 |
-
remove_filter('http_request_timeout', 'wp_smushit_http_request_timeout');
|
300 |
} else {
|
301 |
wp_die( __('WP Smush.it requires WordPress 2.8 or greater', WP_SMUSHIT_DOMAIN) );
|
302 |
}
|
@@ -340,10 +347,12 @@ function wp_smushit_custom_column($column_name, $id) {
|
|
340 |
$id,
|
341 |
__('Re-smush', WP_SMUSHIT_DOMAIN));
|
342 |
} else {
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
347 |
}
|
348 |
}
|
349 |
}
|
@@ -378,14 +387,6 @@ function wp_smushit_bulk_action_handler() {
|
|
378 |
exit();
|
379 |
}
|
380 |
|
381 |
-
/**
|
382 |
-
* http_request_timeout filter -- bumped up to 25 seconds for larger images
|
383 |
-
*/
|
384 |
-
function wp_smushit_http_request_timeout($time) {
|
385 |
-
return 25;
|
386 |
-
}
|
387 |
-
|
388 |
-
|
389 |
if ( function_exists( 'wp_basename' ) === false ) {
|
390 |
/**
|
391 |
* Introduced in WP 3.1... this is copied verbatim from wp-includes/formatting.php.
|
4 |
Plugin URI: http://dialect.ca/code/wp-smushit/
|
5 |
Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
6 |
Author: Dialect
|
7 |
+
Version: 1.6.1
|
8 |
Author URI: http://dialect.ca/
|
9 |
*/
|
10 |
|
23 |
define('SMUSHIT_BASE_URL', 'http://www.smushit.com/');
|
24 |
|
25 |
define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
|
26 |
+
define('WP_SMUSHIT_UA', 'WP Smush.it/1.6.0 (+http://dialect.ca/code/wp-smushit)');
|
27 |
define('WP_SMUSHIT_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
|
28 |
|
29 |
+
define('WP_SMUSHIT_AUTO', intval(get_option('wp_smushit_smushit_auto', 0)));
|
30 |
+
require( dirname(__FILE__) . '/settings.php' );
|
31 |
|
32 |
/**
|
33 |
* Hooks
|
34 |
*/
|
35 |
+
|
36 |
+
if (WP_SMUSHIT_AUTO == WP_SMUSHIT_AUTO_OK) {
|
37 |
+
add_filter('wp_generate_attachment_metadata', 'wp_smushit_resize_from_meta_data', 10, 2);
|
38 |
+
}
|
39 |
add_filter('manage_media_columns', 'wp_smushit_columns');
|
40 |
add_action('manage_media_custom_column', 'wp_smushit_custom_column', 10, 2);
|
41 |
add_action('admin_init', 'wp_smushit_admin_init');
|
54 |
}
|
55 |
add_action( 'admin_menu', 'wp_smushit_admin_menu' );
|
56 |
|
57 |
+
|
58 |
function wp_smushit_bulk_preview() {
|
59 |
if ( function_exists( 'apache_setenv' ) ) {
|
60 |
@apache_setenv('no-gzip', 1);
|
239 |
* Called after `wp_generate_attachment_metadata` is completed.
|
240 |
*/
|
241 |
function wp_smushit_resize_from_meta_data($meta, $ID = null, $force_resmush = true) {
|
242 |
+
if ( $ID && wp_attachment_is_image( $ID ) === false ) {
|
243 |
+
return $meta;
|
244 |
+
}
|
245 |
+
|
246 |
$file_path = $meta['file'];
|
247 |
$store_absolute_path = true;
|
248 |
$upload_dir = wp_upload_dir();
|
253 |
$store_absolute_path = false;
|
254 |
$file_path = $upload_path . $file_path;
|
255 |
}
|
|
|
|
|
|
|
256 |
|
257 |
if ( $force_resmush || wp_smushit_should_resmush( @$meta['wp_smushit'] ) ) {
|
258 |
list($file, $msg) = wp_smushit($file_path);
|
295 |
$data = false;
|
296 |
|
297 |
if ( function_exists('wp_remote_get') ) {
|
298 |
+
$response = wp_remote_get($req, array('user-agent' => WP_SMUSHIT_UA, 'timeout' => 20));
|
|
|
299 |
|
300 |
if( is_wp_error( $response ) ) {
|
301 |
+
wp_smushit_temporarily_disable();
|
302 |
+
$msg = 'Automatic smushing has been disabled temporarily due to an error. ' . $response->get_error_message();
|
303 |
+
wp_die( $msg );
|
304 |
}
|
305 |
|
306 |
$data = wp_remote_retrieve_body($response);
|
|
|
307 |
} else {
|
308 |
wp_die( __('WP Smush.it requires WordPress 2.8 or greater', WP_SMUSHIT_DOMAIN) );
|
309 |
}
|
347 |
$id,
|
348 |
__('Re-smush', WP_SMUSHIT_DOMAIN));
|
349 |
} else {
|
350 |
+
if ( wp_attachment_is_image( $id ) ) {
|
351 |
+
print __('Not processed', WP_SMUSHIT_DOMAIN);
|
352 |
+
printf("<br><a href=\"admin.php?action=wp_smushit_manual&attachment_ID=%d\">%s</a>",
|
353 |
+
$id,
|
354 |
+
__('Smush.it now!', WP_SMUSHIT_DOMAIN));
|
355 |
+
}
|
356 |
}
|
357 |
}
|
358 |
}
|
387 |
exit();
|
388 |
}
|
389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
if ( function_exists( 'wp_basename' ) === false ) {
|
391 |
/**
|
392 |
* Introduced in WP 3.1... this is copied verbatim from wp-includes/formatting.php.
|