ShortPixel Image Optimizer - Version 1.4.1

Version Description

  • optimize again overwrote the original image, fixed
  • fixed restore errors
  • changes to FAQ/Description texts
Download this release

Release Info

Developer ShortPixel
Plugin Icon 128x128 ShortPixel Image Optimizer
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.1

Files changed (3) hide show
  1. readme.txt +24 -11
  2. shortpixel_api.php +6 -3
  3. wp-shortpixel.php +31 -11
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: AlexSP
4
  Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, compression, jpegmini, webp, lossless, cwebp, media, tinypng, jpegtran,image, image optimisation, shrink, picture, photo, optimize photos, compress, performance, tinypng, crunch, pngquant, attachment, optimize, pictures,fast, images, image files, image quality, lossy, upload, kraken, resize, seo, smushit, optipng, kraken image optimizer, ewww, photo optimization, gifsicle, image optimizer, images, krakenio, png, gmagick, image optimize
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.0
7
- Stable tag: 1.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -16,13 +16,13 @@ ShortPixel is an image compression tool that helps improve your website performa
16
 
17
  ShortPixel uses powerful algorithms that enable your website to load faster, use less bandwidth and rank better in search.
18
 
19
- The ShortPixel package includes:
20
 
21
- - Both lossy and lossless optimisation: you can choose between the two types of compression. Lossy for photographs. Lossless for technical drawings, clip art and comics.
22
- - Up to 90% compression rate: with lossy compression images that were 3MB can crunch to 307Kb, with no before/after differences.
23
- - Supported formats: JPG, PNG, GIF (including animated): optimisation applies to JPG, PNG and static GIF. NEW UPDATE: we introduced optimisation for animated GIFs.
24
- - Backup and restore originals: if you ever want to return to the original version, images are automatically stored in a backup folder on your hosting servers.
25
- - Batch image optimisation: Bulk Optimisation tool now available. Crunch your past image gallery, and downsize your website in minutes.
26
 
27
  On the https://ShortPixel.com website, we offer free access to the ShrtPixel API which you can use for further image optimisation purposes.
28
 
@@ -41,6 +41,17 @@ Let's get ShortPixel plugin running on your WordPress website:
41
 
42
  == Frequently Asked Questions ==
43
 
 
 
 
 
 
 
 
 
 
 
 
44
  = Should I pick lossy or lossless optimisation? =
45
 
46
  This depends on your compression needs. Lossy has a better compression rate than lossless compression. The resulting image is not 100% identical with the original. Works well for photos taken with your camera.
@@ -78,10 +89,6 @@ For now, ShortPixel supports JPEG and PNG. Thumbnails are also optimised. Additi
78
 
79
  ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Contact us</a>!
80
 
81
- = What happens with my original images? =
82
-
83
- Your images are automatically stored in a backup folder, on your hosting server. After optimisation, if you want to switch back to a certain original image, hit Restore backup in the Media Library. If you are happy with the ShortPixel optimised images, you can deactivate saving the backups in the plugin Settings.
84
-
85
  == Screenshots ==
86
 
87
  1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
@@ -94,6 +101,12 @@ Your images are automatically stored in a backup folder, on your hosting server.
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
97
  = 1.4.0 =
98
 
99
  * Bulk image processing improved so it can optimize all the images in background while admin page is open
4
  Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, compression, jpegmini, webp, lossless, cwebp, media, tinypng, jpegtran,image, image optimisation, shrink, picture, photo, optimize photos, compress, performance, tinypng, crunch, pngquant, attachment, optimize, pictures,fast, images, image files, image quality, lossy, upload, kraken, resize, seo, smushit, optipng, kraken image optimizer, ewww, photo optimization, gifsicle, image optimizer, images, krakenio, png, gmagick, image optimize
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.0
7
+ Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
16
 
17
  ShortPixel uses powerful algorithms that enable your website to load faster, use less bandwidth and rank better in search.
18
 
19
+ **The ShortPixel package includes:**
20
 
21
+ * **Both lossy and lossless optimisation:** you can choose between the two types of compression. Lossy for photographs. Lossless for technical drawings, clip art and comics.
22
+ * **Up to 90% compression rate:** with lossy compression images that were 3MB can crunch to 307Kb, with no before/after differences.
23
+ * **Supported formats:** JPG, PNG, GIF (including animated): optimisation applies to JPG, PNG and static GIF. NEW UPDATE: we introduced optimisation for animated GIFs.
24
+ * **Backup and restore originals:** if you ever want to return to the original version, images are automatically stored in a backup folder on your hosting servers.
25
+ * **Batch image optimisation:** Bulk Optimisation tool now available. Crunch your past image gallery, and downsize your website in minutes.
26
 
27
  On the https://ShortPixel.com website, we offer free access to the ShrtPixel API which you can use for further image optimisation purposes.
28
 
41
 
42
  == Frequently Asked Questions ==
43
 
44
+ = What happens to the existing images, when installing the ShortPixel plugin? =
45
+
46
+ Just installing the plugin won’t start the optimisation process on existing images. To begin optimising the images previously loaded on your website, you should:
47
+ Go to Media Library, and select which of the existing images you want to optimise.
48
+ OR
49
+ Use the Bulk ShortPixel option, to automatically optimise all your previous library.
50
+
51
+ = What happens with my original images after they have been processed with ShortPixel? =
52
+
53
+ Your images are automatically stored in a backup folder, on your hosting server. After optimisation, if you want to switch back to a certain original image, hit **Restore backup** in the Media Library. If you are happy with the ShortPixel optimised images, you can deactivate saving the backups in the plugin Settings.
54
+
55
  = Should I pick lossy or lossless optimisation? =
56
 
57
  This depends on your compression needs. Lossy has a better compression rate than lossless compression. The resulting image is not 100% identical with the original. Works well for photos taken with your camera.
89
 
90
  ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Contact us</a>!
91
 
 
 
 
 
92
  == Screenshots ==
93
 
94
  1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
101
 
102
  == Changelog ==
103
 
104
+ = 1.4.1 =
105
+
106
+ * optimize again overwrote the original image, fixed
107
+ * fixed restore errors
108
+ * changes to FAQ/Description texts
109
+
110
  = 1.4.0 =
111
 
112
  * Bulk image processing improved so it can optimize all the images in background while admin page is open
shortpixel_api.php CHANGED
@@ -139,10 +139,13 @@ class shortpixel_api {
139
  return printf("Backup folder does not exist and it could not be created");
140
  }
141
 
 
 
 
142
  if(is_writable(SP_BACKUP_FOLDER)) {
143
- $source = $filePath;
144
- $destination = SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($source);
145
- @copy($source, $destination);
146
  } else {
147
  return printf("Backup folder exists but is not writable");
148
  }
139
  return printf("Backup folder does not exist and it could not be created");
140
  }
141
 
142
+ $source = $filePath;
143
+ $destination = SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($source);
144
+
145
  if(is_writable(SP_BACKUP_FOLDER)) {
146
+ if(!file_exists($destination)) {
147
+ @copy($source, $destination);
148
+ }
149
  } else {
150
  return printf("Backup folder exists but is not writable");
151
  }
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimiser
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimises images automatically using both lossy and lossless compression. Resulting, smaller, images are no different in quality from the original. To install: 1) Click the "Activate" link to the left of this description. 2) <a href="https://shortpixel.com/wp-apikey" target="_blank">Free Sign up</a> for your unique API Key . 3) Check your email for your API key. 4) Use your API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress. 5) Done!
6
- * Version: 1.4.0
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -45,6 +45,7 @@ class WPShortPixel {
45
  add_action( 'admin_menu', array( &$this, 'registerSettingsPage' ) );
46
  add_action( 'admin_menu', array( &$this, 'registerAdminPage' ) );
47
  add_action( 'admin_notices', array( &$this, 'displayNotice' ) );
 
48
 
49
  //automatic optimization
50
  add_action( 'admin_footer', array( &$this, 'my_action_javascript') );
@@ -246,10 +247,12 @@ class WPShortPixel {
246
  //main file
247
  @rename(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($uploadFilePath), $uploadFilePath);
248
  //overwriting thumbnails
249
- foreach($meta["sizes"] as $size => $imageData) {
250
- $source = SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . $imageData['file'];
251
- $destination = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $imageData['file'];
252
- @rename($source, $destination);
 
 
253
  }
254
 
255
  unset($meta["ShortPixelImprovement"]);
@@ -267,6 +270,24 @@ class WPShortPixel {
267
  // we are done
268
  }
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  public function bulkOptimizeActionHandler($hook) {
271
  if($hook == 'upload.php') {
272
  if($_GET['action'] == 2) {
@@ -300,7 +321,7 @@ class WPShortPixel {
300
  }
301
 
302
  public function bulkProcesss() {
303
- echo '<h1>ShortPixel Bulk Processing</h1>';
304
 
305
  echo '
306
  <script type="text/javascript" >
@@ -318,8 +339,8 @@ class WPShortPixel {
318
  ';
319
 
320
  if(MUST_HAVE_KEY && $this->_verifiedKey == false) {
321
- echo "<p>You do not have an API Key set. Bulk processing cannot be used. </p>";
322
- echo "<p>Don’t have an API Key? <a href=\"https://shortpixel.com/wp-apikey\" target=\"_blank\">Sign up, it’s free.</a> </p>";
323
  return;
324
  }
325
 
@@ -351,9 +372,8 @@ class WPShortPixel {
351
 
352
  if($currentBulkProcessingStatus && $currentBulkProcessingStatus['running']) {
353
  echo "<p>
354
- Bulk processing started and it may take a while we process your images in the background. </br>
355
- This page will refresh every 30 seconds in order to display the latest status of the processing. </br>
356
- In the mean time you can continue using the admin as usually.
357
  </p>";
358
  echo '
359
  <script type="text/javascript" >
3
  * Plugin Name: ShortPixel Image Optimiser
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimises images automatically using both lossy and lossless compression. Resulting, smaller, images are no different in quality from the original. To install: 1) Click the "Activate" link to the left of this description. 2) <a href="https://shortpixel.com/wp-apikey" target="_blank">Free Sign up</a> for your unique API Key . 3) Check your email for your API key. 4) Use your API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress. 5) Done!
6
+ * Version: 1.4.1
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
45
  add_action( 'admin_menu', array( &$this, 'registerSettingsPage' ) );
46
  add_action( 'admin_menu', array( &$this, 'registerAdminPage' ) );
47
  add_action( 'admin_notices', array( &$this, 'displayNotice' ) );
48
+ add_action( 'delete_attachment', array( &$this, 'handleDeleteAttachmentInBackup' ) );
49
 
50
  //automatic optimization
51
  add_action( 'admin_footer', array( &$this, 'my_action_javascript') );
247
  //main file
248
  @rename(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($uploadFilePath), $uploadFilePath);
249
  //overwriting thumbnails
250
+ if(is_array($meta["sizes"])) {
251
+ foreach($meta["sizes"] as $size => $imageData) {
252
+ $source = SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . $imageData['file'];
253
+ $destination = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $imageData['file'];
254
+ @rename($source, $destination);
255
+ }
256
  }
257
 
258
  unset($meta["ShortPixelImprovement"]);
270
  // we are done
271
  }
272
 
273
+
274
+ public function handleDeleteAttachmentInBackup($ID) {
275
+ $uploadFilePath = get_attached_file($ID);
276
+ $meta = wp_get_attachment_metadata($ID);
277
+
278
+ try {
279
+ //main file
280
+ @unlink(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($uploadFilePath));
281
+ //overwriting thumbnails
282
+ foreach($meta["sizes"] as $size => $imageData) {
283
+ @unlink(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . $imageData['file']);
284
+ }
285
+ } catch(Exception $e) {
286
+ //what to do, what to do?
287
+ }
288
+
289
+ }
290
+
291
  public function bulkOptimizeActionHandler($hook) {
292
  if($hook == 'upload.php') {
293
  if($_GET['action'] == 2) {
321
  }
322
 
323
  public function bulkProcesss() {
324
+ echo '<h1>Bulk Image Optimisation by ShortPixel</h1>';
325
 
326
  echo '
327
  <script type="text/javascript" >
339
  ';
340
 
341
  if(MUST_HAVE_KEY && $this->_verifiedKey == false) {
342
+ echo "<p>In order to start processing your images, you need to validate your API key in the ShortPixel Settings. If you don’t have an API Key, you can get one delivered to your inbox.</p>";
343
+ echo "<p>Don’t have an API Key yet? Get it now at <a href=\"https://shortpixel.com/wp-apikey\" target=\"_blank\">www.ShortPixel.com</a>, for free.</p>";
344
  return;
345
  }
346
 
372
 
373
  if($currentBulkProcessingStatus && $currentBulkProcessingStatus['running']) {
374
  echo "<p>
375
+ Bulk optimisation has started. It may take a while until we process all your images. The latest status of the processing will be displayed here every 30 seconds.
376
+ In the meantime, you can continue using the admin as usual. However, <b>you musn’t close the WordPress admin</b>, or the bulk processing will stop.
 
377
  </p>";
378
  echo '
379
  <script type="text/javascript" >