ShortPixel Image Optimizer - Version 1.6.7

Version Description

  • extra check for exif_imagetype function
Download this release

Release Info

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

Code changes from version 1.6.6 to 1.6.7

Files changed (2) hide show
  1. readme.txt +5 -1
  2. wp-shortpixel.php +18 -21
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.1
7
- Stable tag: 1.6.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -107,6 +107,10 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
107
 
108
  == Changelog ==
109
 
 
 
 
 
110
  = 1.6.6 =
111
 
112
  * changed method from GET to POST for API Key validation
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.1
7
+ Stable tag: 1.6.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
107
 
108
  == Changelog ==
109
 
110
+ = 1.6.7 =
111
+
112
+ * extra check for exif_imagetype function
113
+
114
  = 1.6.6 =
115
 
116
  * changed method from GET to POST for API Key validation
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.6.6
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -150,7 +150,7 @@ class WPShortPixel {
150
  self::log("Processing image id {$ID}");
151
  $url = wp_get_attachment_url($ID);
152
  $path = get_attached_file($ID);
153
- if(exif_imagetype($path) != false) {
154
  $this->_apiInterface->doRequests($url, $path, $ID);
155
 
156
  //send request for thumbs as well
@@ -306,7 +306,7 @@ class WPShortPixel {
306
  public function handleDeleteAttachmentInBackup($ID) {
307
  $uploadFilePath = get_attached_file($ID);
308
  $meta = wp_get_attachment_metadata($ID);
309
- if(exif_imagetype($uploadFilePath) != false) {
310
  try {
311
  //main file
312
  @unlink(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($uploadFilePath));
@@ -374,29 +374,12 @@ class WPShortPixel {
374
  if($_POST["bulkProcess"]) {
375
  //remove all ShortPixel data from metadata
376
  foreach($attachments as $attachment) {
377
- if(exif_imagetype(get_attached_file($attachment->ID)) == false) continue;
378
  $meta = wp_get_attachment_metadata($attachment->ID);
379
  $meta['ShortPixel']['BulkProcessing'] = true;
380
  wp_update_attachment_metadata($attachment->ID, $meta);
381
  }
382
 
383
- //break this in separate foreach in order to easily comment it out if performance issues
384
- // foreach($attachments as $attachment) {
385
- // if(exif_imagetype(get_attached_file($attachment->ID)) == false) continue;
386
- // $meta = wp_get_attachment_metadata($attachment->ID);
387
- // $url = wp_get_attachment_url($attachment->ID);
388
- // $path = get_attached_file($attachment->ID);
389
- // $this->_apiInterface->doRequests($url, $path, $attachment->ID);
390
- //
391
- // if($this->_processThumbnails && !empty($meta['sizes'])) {
392
- // foreach($meta['sizes'] as $thumbnailInfo) {
393
- // $thumbURL = str_replace(basename($url), $thumbnailInfo['file'], $url);
394
- // $thumbPath = str_replace(basename($path), $thumbnailInfo['file'], $path);
395
- // $this->_apiInterface->doRequests($thumbURL, $thumbPath);
396
- // }
397
- // }
398
- // }
399
-
400
  update_option('bulkProcessingStatus', 'running');
401
  }
402
 
@@ -796,6 +779,20 @@ HTML;
796
  return round($bytes, $precision) . ' ' . $units[$pow];
797
  }
798
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  static public function folderSize($path) {
800
  $total_size = 0;
801
  if(file_exists($path)) {
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.6.7
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
150
  self::log("Processing image id {$ID}");
151
  $url = wp_get_attachment_url($ID);
152
  $path = get_attached_file($ID);
153
+ if(self::isImage($path) != false) {
154
  $this->_apiInterface->doRequests($url, $path, $ID);
155
 
156
  //send request for thumbs as well
306
  public function handleDeleteAttachmentInBackup($ID) {
307
  $uploadFilePath = get_attached_file($ID);
308
  $meta = wp_get_attachment_metadata($ID);
309
+ if(self::isImage($uploadFilePath) != false) {
310
  try {
311
  //main file
312
  @unlink(SP_BACKUP_FOLDER . DIRECTORY_SEPARATOR . basename($uploadFilePath));
374
  if($_POST["bulkProcess"]) {
375
  //remove all ShortPixel data from metadata
376
  foreach($attachments as $attachment) {
377
+ if(self::isImage(get_attached_file($attachment->ID)) == false) continue;
378
  $meta = wp_get_attachment_metadata($attachment->ID);
379
  $meta['ShortPixel']['BulkProcessing'] = true;
380
  wp_update_attachment_metadata($attachment->ID, $meta);
381
  }
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  update_option('bulkProcessingStatus', 'running');
384
  }
385
 
779
  return round($bytes, $precision) . ' ' . $units[$pow];
780
  }
781
 
782
+ static public function isImage($path) {
783
+ if(function_exists('exif_imagetype')) {
784
+ return exif_imagetype($path);
785
+ } else {
786
+ $pathParts = pathinfo($path);
787
+ if(in_array($pathParts['extension'], array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
788
+ return true;
789
+ } else {
790
+ return false;
791
+ }
792
+ }
793
+
794
+ }
795
+
796
  static public function folderSize($path) {
797
  $total_size = 0;
798
  if(file_exists($path)) {