ShortPixel Image Optimizer - Version 4.2.9

Version Description

  • fix bug when thumbnails had numeric indexes in the sizes metadata array
  • fix bug when bulk reoptimizing on some specific conditions
Download this release

Release Info

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

Code changes from version 4.2.8 to 4.2.9

class/db/shortpixel-meta-facade.php CHANGED
@@ -84,7 +84,7 @@ class ShortPixelMetaFacade {
84
  return $rawMeta;
85
  }
86
 
87
- function updateMeta($newMeta = null) {
88
  if($newMeta) {
89
  $this->meta = $newMeta;
90
  }
@@ -100,7 +100,16 @@ class ShortPixelMetaFacade {
100
  $rawMeta = $this->sanitizeMeta(wp_get_attachment_metadata($_ID));
101
 
102
  if(is_array($rawMeta['sizes'])) {
103
- $rawMeta['sizes'] = array_merge($rawMeta['sizes'], $this->meta->getThumbs());
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
  if(null === $this->meta->getCompressionType()) {
@@ -145,7 +154,7 @@ class ShortPixelMetaFacade {
145
  if($this->meta->getThumbsTodo()) {
146
  $rawMeta['ShortPixel']['thumbsTodo'] = true;
147
  } else {
148
- if($this->meta->getStatus() > 0) {
149
  $rawMeta['ShortPixelImprovement'] = "".round($this->meta->getImprovementPercent(),2);
150
  }
151
  unset($rawMeta['ShortPixel']['thumbsTodo']);
84
  return $rawMeta;
85
  }
86
 
87
+ function updateMeta($newMeta = null, $replaceThumbs = false) {
88
  if($newMeta) {
89
  $this->meta = $newMeta;
90
  }
100
  $rawMeta = $this->sanitizeMeta(wp_get_attachment_metadata($_ID));
101
 
102
  if(is_array($rawMeta['sizes'])) {
103
+ if($replaceThumbs) {
104
+ $rawMeta['sizes'] = $this->meta->getThumbs();
105
+ } else {
106
+ //use this instead of array_merge because we don't want to duplicate numeric keys
107
+ foreach($this->meta->getThumbs() as $key => $val) {
108
+ if(!isset($rawMeta['sizes'][$key])) {
109
+ $rawMeta['sizes'][$key] = $val;
110
+ }
111
+ }
112
+ }
113
  }
114
 
115
  if(null === $this->meta->getCompressionType()) {
154
  if($this->meta->getThumbsTodo()) {
155
  $rawMeta['ShortPixel']['thumbsTodo'] = true;
156
  } else {
157
+ if($this->meta->getStatus() > 1) {
158
  $rawMeta['ShortPixelImprovement'] = "".round($this->meta->getImprovementPercent(),2);
159
  }
160
  unset($rawMeta['ShortPixel']['thumbsTodo']);
class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -145,12 +145,15 @@ class WpShortPixelMediaLbraryAdapter {
145
  $meta = $itemHandler->getMeta();
146
  $sizesAll = $meta->getThumbs();
147
  $sizes = array();
 
148
  foreach($sizesAll as $key => $size) {
149
- if (strpos($key, ShortPixelMeta::FOUND_THUMB_PREFIX) === 0) continue;
 
150
  $sizes[$key] = $size;
 
151
  }
152
  $meta->setThumbs($sizes);
153
- $itemHandler->updateMeta($meta);
154
  }
155
 
156
  public static function findThumbs($mainFile) {
145
  $meta = $itemHandler->getMeta();
146
  $sizesAll = $meta->getThumbs();
147
  $sizes = array();
148
+ $files = array();
149
  foreach($sizesAll as $key => $size) {
150
+ if(strpos($key, ShortPixelMeta::FOUND_THUMB_PREFIX) === 0) continue;
151
+ if(in_array($size['file'], $files)) continue;
152
  $sizes[$key] = $size;
153
+ $files[] = $size['file'];
154
  }
155
  $meta->setThumbs($sizes);
156
+ $itemHandler->updateMeta($meta, true);
157
  }
158
 
159
  public static function findThumbs($mainFile) {
class/wp-short-pixel.php CHANGED
@@ -875,6 +875,7 @@ class WPShortPixel {
875
  }
876
 
877
  private function sendToProcessing($itemHandler, $compressionType = false, $onlyThumbs = false) {
 
878
  $URLsAndPATHs = $this->getURLsAndPATHs($itemHandler, NULL, $onlyThumbs);
879
 
880
  $meta = $itemHandler->getMeta();
@@ -2079,7 +2080,9 @@ class WPShortPixel {
2079
  $data['ShortPixelImprovement'] = '';
2080
  }
2081
 
2082
- if(is_numeric($data['ShortPixelImprovement'])) { //already optimized
 
 
2083
  $sizesCount = isset($data['sizes']) ? WpShortPixelMediaLbraryAdapter::countNonWebpSizes($data['sizes']) : 0;
2084
 
2085
  $renderData['status'] = $fileExtension == "pdf" ? 'pdfOptimized' : 'imgOptimized';
875
  }
876
 
877
  private function sendToProcessing($itemHandler, $compressionType = false, $onlyThumbs = false) {
878
+ //WpShortPixelMediaLbraryAdapter::cleanupFoundThumbs($itemHandler);
879
  $URLsAndPATHs = $this->getURLsAndPATHs($itemHandler, NULL, $onlyThumbs);
880
 
881
  $meta = $itemHandler->getMeta();
2080
  $data['ShortPixelImprovement'] = '';
2081
  }
2082
 
2083
+ if( is_numeric($data['ShortPixelImprovement'])
2084
+ && !($data['ShortPixelImprovement'] == 0 && isset($data['ShortPixel']['WaitingProcessing'])) //for images that erroneously have ShortPixelImprovement = 0 when WaitingProcessing
2085
+ ) { //already optimized
2086
  $sizesCount = isset($data['sizes']) ? WpShortPixelMediaLbraryAdapter::countNonWebpSizes($data['sizes']) : 0;
2087
 
2088
  $renderData['status'] = $fileExtension == "pdf" ? 'pdfOptimized' : 'imgOptimized';
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: image optimizer, image optimization, compress pdf, compress jpeg, compress
5
 
6
  Requires at least: 3.2.0
7
  Tested up to: 4.7
8
- Stable tag: 4.2.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -217,6 +217,11 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
217
 
218
  == Changelog ==
219
 
 
 
 
 
 
220
  = 4.2.8 =
221
 
222
  * fix bug when searching for thumbanils of files with same prefix
5
 
6
  Requires at least: 3.2.0
7
  Tested up to: 4.7
8
+ Stable tag: 4.2.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
217
 
218
  == Changelog ==
219
 
220
+ = 4.2.9 =
221
+
222
+ * fix bug when thumbnails had numeric indexes in the sizes metadata array
223
+ * fix bug when bulk reoptimizing on some specific conditions
224
+
225
  = 4.2.8 =
226
 
227
  * fix bug when searching for thumbanils of files with same prefix
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.2.8
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -18,7 +18,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
18
 
19
  define('SP_AFFILIATE_CODE', '');
20
 
21
- define('PLUGIN_VERSION', "4.2.8");
22
  define('SP_MAX_TIMEOUT', 10);
23
  define('SP_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SP_BACKUP', 'ShortpixelBackups');
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.2.9
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
18
 
19
  define('SP_AFFILIATE_CODE', '');
20
 
21
+ define('PLUGIN_VERSION', "4.2.9");
22
  define('SP_MAX_TIMEOUT', 10);
23
  define('SP_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SP_BACKUP', 'ShortpixelBackups');