ShortPixel Image Optimizer - Version 4.13.1

Version Description

Release date: 16th April 2019 * fix thumbnail optimization when a thumbnail was replaced with another one * better integration with Regenerate Thumbnails Advanced

Download this release

Release Info

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

Code changes from version 4.13.0 to 4.13.1

class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -242,7 +242,7 @@ class WpShortPixelMediaLbraryAdapter {
242
  return $wpdb->get_results($queryPostMeta);
243
  }
244
 
245
- public static function countSizesNotExcluded($sizes, $exclude = false) {
246
  $uniq = array();
247
  $exclude = is_array($exclude) ? $exclude : array(); //this is because it sometimes receives directly the setting which could be false
248
  foreach($sizes as $key => $val) {
@@ -254,9 +254,15 @@ class WpShortPixelMediaLbraryAdapter {
254
  if(is_array($file)) { $file = $file[0];} // HelpScout case 709692915
255
  $uniq[$file] = $key;
256
  }
257
- return count($uniq);
258
  }
259
 
 
 
 
 
 
 
260
  public static function cleanupFoundThumbs($itemHandler) {
261
  $meta = $itemHandler->getMeta();
262
  $sizesAll = $meta->getThumbs();
242
  return $wpdb->get_results($queryPostMeta);
243
  }
244
 
245
+ public static function getSizesNotExcluded($sizes, $exclude = false) {
246
  $uniq = array();
247
  $exclude = is_array($exclude) ? $exclude : array(); //this is because it sometimes receives directly the setting which could be false
248
  foreach($sizes as $key => $val) {
254
  if(is_array($file)) { $file = $file[0];} // HelpScout case 709692915
255
  $uniq[$file] = $key;
256
  }
257
+ return $uniq;
258
  }
259
 
260
+ public static function countSizesNotExcluded($sizes, $exclude = false)
261
+ {
262
+ return count(self::getSizesNotExcluded($sizes, $exclude));
263
+ }
264
+
265
+
266
  public static function cleanupFoundThumbs($itemHandler) {
267
  $meta = $itemHandler->getMeta();
268
  $sizesAll = $meta->getThumbs();
class/wp-short-pixel.php CHANGED
@@ -2103,11 +2103,48 @@ class WPShortPixel {
2103
  $ID = intval($_GET['attachment_ID']);
2104
  $meta = wp_get_attachment_metadata($ID);
2105
  //die(var_dump($meta));
2106
- $thumbsCount = WpShortPixelMediaLbraryAdapter::countSizesNotExcluded($meta['sizes'], $this->_settings->excludeSizes);
2107
- if( isset($meta['ShortPixelImprovement'])
2108
- && isset($meta['sizes']) && $thumbsCount
2109
- && ( !isset($meta['ShortPixel']['thumbsOpt']) || $meta['ShortPixel']['thumbsOpt'] == 0
2110
- || (isset($meta['sizes']) && isset($meta['ShortPixel']['thumbsOptList']) && $meta['ShortPixel']['thumbsOpt'] < $thumbsCount))) { //optimized without thumbs, thumbs exist
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2111
  $meta['ShortPixel']['thumbsTodo'] = true;
2112
  //wp_update_attachment_metadata($ID, $meta);
2113
  update_post_meta($ID, '_wp_attachment_metadata', $meta);
2103
  $ID = intval($_GET['attachment_ID']);
2104
  $meta = wp_get_attachment_metadata($ID);
2105
  //die(var_dump($meta));
2106
+
2107
+ //$thumbsCount = WpShortPixelMediaLbraryAdapter::countSizesNotExcluded($meta['sizes'], $this->_settings->excludeSizes);
2108
+ $error = array('Status' => ShortPixelAPI::STATUS_SKIP, 'message' => __('Unspecified Error on Thumbnails for: ') . $ID);
2109
+ $includedSizes = WpShortPixelMediaLbraryAdapter::getSizesNotExcluded($meta['sizes'], $this->_settings->excludeSizes);
2110
+ $thumbsCount = count($includedSizes);
2111
+
2112
+ if (! isset($meta['ShortPixelImprovement']))
2113
+ {
2114
+ $error['message'] = __('Please optimize image for ID: ','shortpixel-image-optimiser') . $ID;
2115
+ die(json_encode($error));
2116
+ }
2117
+ if (! isset($meta['sizes']) || count($meta['sizes']) == 0)
2118
+ {
2119
+ $error['message'] = __('No thumbnails to optimize for ID: ','shortpixel-image-optimiser') . $ID;
2120
+ die(json_encode($error));
2121
+ }
2122
+ /* Check ThumbList against current Sizes. It's possible when a size was dropped, the SP meta was not updated, playing
2123
+ * tricks with the thumbcount.
2124
+ *
2125
+ */
2126
+ if (isset($meta['ShortPixel']['thumbsOptList']) && is_array($meta['ShortPixel']['thumbsOptList']))
2127
+ {
2128
+ $thumbList = array();
2129
+ foreach($meta['ShortPixel']['thumbsOptList'] as $fileName)
2130
+ {
2131
+ if (isset($includedSizes[$fileName]))
2132
+ {
2133
+ $thumbList[] = $fileName;
2134
+ }
2135
+ }
2136
+ $meta['ShortPixel']['thumbsOptList'] = $thumbList;
2137
+ }
2138
+
2139
+
2140
+ // if( isset($meta['ShortPixelImprovement'])
2141
+ // && isset($meta['sizes']) && $thumbsCount
2142
+ // && ( !isset($meta['ShortPixel']['thumbsOpt']) || $meta['ShortPixel']['thumbsOpt'] == 0
2143
+ // || (isset($meta['sizes']) && isset($meta['ShortPixel']['thumbsOptList']) && $meta['ShortPixel']['thumbsOpt'] < $thumbsCount))) { //optimized without thumbs, thumbs exist
2144
+
2145
+ if( $thumbsCount
2146
+ && (isset($meta['sizes']) && isset($meta['ShortPixel']['thumbsOptList']) && count($meta['ShortPixel']['thumbsOptList']) < $thumbsCount))
2147
+ {
2148
  $meta['ShortPixel']['thumbsTodo'] = true;
2149
  //wp_update_attachment_metadata($ID, $meta);
2150
  update_post_meta($ID, '_wp_attachment_metadata', $meta);
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: ShortPixel
3
  Tags: compressor, image, compression, optimize, image optimizer, image optimiser, image compression, resize, compress pdf, compress jpg, compress png, image compression
4
  Requires at least: 3.2.0
5
- Tested up to: 5.1
6
- Requires PHP: 5.2
7
- Stable tag: 4.13.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -241,6 +241,12 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
244
  = 4.13.0 =
245
 
246
  Release date: 10th April 2019
2
  Contributors: ShortPixel
3
  Tags: compressor, image, compression, optimize, image optimizer, image optimiser, image compression, resize, compress pdf, compress jpg, compress png, image compression
4
  Requires at least: 3.2.0
5
+ Tested up to: 5.2
6
+ Requires PHP: 5.3
7
+ Stable tag: 4.13.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
241
 
242
  == Changelog ==
243
 
244
+ = 4.13.1 =
245
+
246
+ Release date: 16th April 2019
247
+ * fix thumbnail optimization when a thumbnail was replaced with another one
248
+ * better integration with Regenerate Thumbnails Advanced
249
+
250
  = 4.13.0 =
251
 
252
  Release date: 10th April 2019
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.13.0
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('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.13.0");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_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.13.1
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
18
 
19
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.13.1");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');