Version Description
Download this release
Release Info
Developer | alexdunae |
Plugin | Smush Image Compression and Optimization |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.1.1
- history.txt +3 -0
- readme.txt +2 -2
- smush.php +2 -2
- wp-smushit.php +8 -8
history.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
=== WP Smush.it Release History ===
|
2 |
|
|
|
|
|
|
|
3 |
== 1.1 ==
|
4 |
* improved handling of errors from Smush.it
|
5 |
* added ability to manually smush images from media library
|
1 |
=== WP Smush.it Release History ===
|
2 |
|
3 |
+
== 1.1.1 ==
|
4 |
+
* added error message on PHP copy error
|
5 |
+
|
6 |
== 1.1 ==
|
7 |
* improved handling of errors from Smush.it
|
8 |
* added ability to manually smush images from media library
|
readme.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
-
Version: 1.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.5
|
9 |
Tested up to: 2.7
|
10 |
-
Stable tag: 1.1
|
11 |
|
12 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
13 |
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
+
Version: 1.1,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.5
|
9 |
Tested up to: 2.7
|
10 |
+
Stable tag: 1.1.1
|
11 |
|
12 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
13 |
|
smush.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* Expects an `attachment_ID` in the query string.
|
6 |
*
|
7 |
-
* @version 1.1
|
8 |
* @package WP_SmushIt
|
9 |
*/
|
10 |
|
@@ -23,7 +23,7 @@ wp_update_attachment_metadata( $attachment_ID, $new_meta );
|
|
23 |
|
24 |
$sendback = wp_get_referer();
|
25 |
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
|
26 |
-
|
27 |
wp_redirect($sendback);
|
28 |
|
29 |
exit(0);
|
4 |
*
|
5 |
* Expects an `attachment_ID` in the query string.
|
6 |
*
|
7 |
+
* @version 1.1.1
|
8 |
* @package WP_SmushIt
|
9 |
*/
|
10 |
|
23 |
|
24 |
$sendback = wp_get_referer();
|
25 |
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
|
26 |
+
|
27 |
wp_redirect($sendback);
|
28 |
|
29 |
exit(0);
|
wp-smushit.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Integrate the Smush.it API into WordPress.
|
4 |
-
* @version 1.1
|
5 |
* @package WP_SmushIt
|
6 |
*/
|
7 |
/*
|
@@ -9,7 +9,7 @@ Plugin Name: WP Smush.it
|
|
9 |
Plugin URI: http://dialect.ca/code/wp-smushit/
|
10 |
Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
11 |
Author: Dialect
|
12 |
-
Version: 1.1
|
13 |
Author URI: http://dialect.ca/?wp_smush_it
|
14 |
*/
|
15 |
|
@@ -59,7 +59,7 @@ add_action('admin_init', 'wp_smushit_init');
|
|
59 |
*/
|
60 |
function wp_smushit($file) {
|
61 |
// dont't run on localhost
|
62 |
-
if(
|
63 |
return array($file, __('Not processed (local file)', WP_SMUSHIT_DOMAIN));
|
64 |
|
65 |
|
@@ -99,7 +99,7 @@ function wp_smushit($file) {
|
|
99 |
$data = $json->decode($data);
|
100 |
}
|
101 |
|
102 |
-
if ( intval($data->dest_size)
|
103 |
return array($file, __('No savings', WP_SMUSHIT_DOMAIN));
|
104 |
|
105 |
if ( !$data->dest ) {
|
@@ -113,12 +113,12 @@ function wp_smushit($file) {
|
|
113 |
$temp_file = tempnam( WP_CONTENT_DIR, '___' );
|
114 |
|
115 |
if( !@copy( $processed_url, $temp_file ) )
|
116 |
-
return
|
117 |
|
118 |
chmod( $temp_file, 0644 );
|
119 |
|
120 |
// check if Smush.it converted a GIF to a PNG
|
121 |
-
if(
|
122 |
$file = preg_replace('/.gif$/i', '.png', $file);
|
123 |
$file_path = preg_replace('/.gif$/i', '.png', $file_path);
|
124 |
|
@@ -222,8 +222,8 @@ function wp_smushit_custom_column($column_name, $id) {
|
|
222 |
* @returns bool
|
223 |
*/
|
224 |
function wp_smushit_did_gif_to_png($orig, $new) {
|
225 |
-
return (stripos(strrev($new), 'gnp.')
|
226 |
-
stripos(strrev($orig), 'fig.')
|
227 |
|
228 |
}
|
229 |
|
1 |
<?php
|
2 |
/**
|
3 |
* Integrate the Smush.it API into WordPress.
|
4 |
+
* @version 1.1.1
|
5 |
* @package WP_SmushIt
|
6 |
*/
|
7 |
/*
|
9 |
Plugin URI: http://dialect.ca/code/wp-smushit/
|
10 |
Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
11 |
Author: Dialect
|
12 |
+
Version: 1.1.1
|
13 |
Author URI: http://dialect.ca/?wp_smush_it
|
14 |
*/
|
15 |
|
59 |
*/
|
60 |
function wp_smushit($file) {
|
61 |
// dont't run on localhost
|
62 |
+
if( '127.0.0.1' == $_SERVER['SERVER_ADDR'] )
|
63 |
return array($file, __('Not processed (local file)', WP_SMUSHIT_DOMAIN));
|
64 |
|
65 |
|
99 |
$data = $json->decode($data);
|
100 |
}
|
101 |
|
102 |
+
if ( -1 == intval($data->dest_size) )
|
103 |
return array($file, __('No savings', WP_SMUSHIT_DOMAIN));
|
104 |
|
105 |
if ( !$data->dest ) {
|
113 |
$temp_file = tempnam( WP_CONTENT_DIR, '___' );
|
114 |
|
115 |
if( !@copy( $processed_url, $temp_file ) )
|
116 |
+
return array($file, __('Error updating file', WP_SMUSHIT_DOMAIN) );
|
117 |
|
118 |
chmod( $temp_file, 0644 );
|
119 |
|
120 |
// check if Smush.it converted a GIF to a PNG
|
121 |
+
if( 1 == WP_SMUSHIT_GIF_TO_PNG && wp_smushit_did_gif_to_png($file, $data->dest) ) {
|
122 |
$file = preg_replace('/.gif$/i', '.png', $file);
|
123 |
$file_path = preg_replace('/.gif$/i', '.png', $file_path);
|
124 |
|
222 |
* @returns bool
|
223 |
*/
|
224 |
function wp_smushit_did_gif_to_png($orig, $new) {
|
225 |
+
return (0 === stripos(strrev($new), 'gnp.') &&
|
226 |
+
0 === stripos(strrev($orig), 'fig.') );
|
227 |
|
228 |
}
|
229 |
|