ShortPixel Image Optimizer - Version 4.22.3

Version Description

Release date July 28th, 2021 * Fix: Error when using WordPress 5.8 Widget editor; * Fix: Error when using WP-Offload and WebP image could not be detected; * Fix: PNG2JPG when using WP without date directory format would incorrectly add ./ to filename; * Fix: Unregistered retina files could throw off optimization; * Fix: Easy Watermark plugin changed its main file, so it couldn't be properly detected; * Language: 0 new string added, 0 updated, 0 fuzzed, and 0 obsoleted.

Download this release

Release Info

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

Code changes from version 4.22.2 to 4.22.3

class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -561,6 +561,12 @@ class WpShortPixelMediaLbraryAdapter {
561
  continue;
562
  }
563
 
 
 
 
 
 
 
564
  if(!in_array($size, $exclude) && !in_array($file->getFileName(), $thumbsOptList)) {
565
  $thumbsToOptimizeList[] = $file->getFileName();
566
  }
561
  continue;
562
  }
563
 
564
+ // Drop @2x (retina) images from the size. Some plugins generate retinas, add them to the sizes without registering them, which leads to confusing of the plugin since retinas are not stored under the optimize thumbslist.
565
+ if (strpos($size, '@2x') !== false || strpos($file->getFileName(), '@2x') !== false)
566
+ {
567
+ continue;
568
+ }
569
+
570
  if(!in_array($size, $exclude) && !in_array($file->getFileName(), $thumbsOptList)) {
571
  $thumbsToOptimizeList[] = $file->getFileName();
572
  }
class/external/wp-offload-media.php CHANGED
@@ -353,9 +353,10 @@ class wpOffload
353
  }
354
 
355
  // GetbyURL can't find thumbnails, only the main image. We are going to assume, if imagebase is ok, the webp might be there.
 
356
  public function fixWebpRemotePath($bool, $file, $url, $imagebase)
357
  {
358
- if (strpos($url, $imagebase->getPath()) !== false)
359
  return $file;
360
  else
361
  return $bool;
353
  }
354
 
355
  // GetbyURL can't find thumbnails, only the main image. We are going to assume, if imagebase is ok, the webp might be there.
356
+ // ImageBase is fileDir as String, not object!
357
  public function fixWebpRemotePath($bool, $file, $url, $imagebase)
358
  {
359
+ if (strpos($url, $imagebase) !== false)
360
  return $file;
361
  else
362
  return $bool;
class/front/img-to-picture-webp.php CHANGED
@@ -135,7 +135,6 @@ class ShortPixelImgToPictureWebp
135
  }
136
 
137
  $img = $this->get_attributes($match[0]);
138
- // echo "<PRE>"; var_dump($img); echo "</PRE>";
139
 
140
  if(isset($img['style']) && strpos($img['style'], 'background') !== false) {
141
  //don't replace for <img>'s that have background
@@ -149,6 +148,12 @@ class ShortPixelImgToPictureWebp
149
  return $match[0];
150
  }
151
 
 
 
 
 
 
 
152
  $srcInfo = $this->lazyGet($img, 'src');
153
  $srcsetInfo = $this->lazyGet($img, 'srcset');
154
  $sizesInfo = $this->lazyGet($img, 'sizes');
@@ -159,7 +164,7 @@ class ShortPixelImgToPictureWebp
159
  Log::addInfo('SPDBG baseurl doesn\'t match ' . $srcInfo['value'], array($imageBase) );
160
  return $match[0]; // . (isset($_GET['SHORTPIXEL_DEBUG']) ? '<!-- SPDBG baseurl doesn\'t match ' . $src . ' -->' : '');
161
  }
162
- Log::addDebug('ImageBase'. $imageBase);
163
 
164
  //some attributes should not be moved from <img>
165
  // @todo Move these to unset on (imgpicture) and put via create_attributes back
135
  }
136
 
137
  $img = $this->get_attributes($match[0]);
 
138
 
139
  if(isset($img['style']) && strpos($img['style'], 'background') !== false) {
140
  //don't replace for <img>'s that have background
148
  return $match[0];
149
  }
150
 
151
+ // No src is not something we can handle. This can happen when creating an image in WP Gutenberg but not setting any image file on the block, but adding something like a custom class
152
+ if (! isset($img['src']) && ! isset($img['srcset']))
153
+ {
154
+ return $match[0];
155
+ }
156
+
157
  $srcInfo = $this->lazyGet($img, 'src');
158
  $srcsetInfo = $this->lazyGet($img, 'srcset');
159
  $sizesInfo = $this->lazyGet($img, 'sizes');
164
  Log::addInfo('SPDBG baseurl doesn\'t match ' . $srcInfo['value'], array($imageBase) );
165
  return $match[0]; // . (isset($_GET['SHORTPIXEL_DEBUG']) ? '<!-- SPDBG baseurl doesn\'t match ' . $src . ' -->' : '');
166
  }
167
+ Log::addDebug('ImageBase -'. $imageBase);
168
 
169
  //some attributes should not be moved from <img>
170
  // @todo Move these to unset on (imgpicture) and put via create_attributes back
class/shortpixel-png2jpg.php CHANGED
@@ -316,7 +316,13 @@ class ShortPixelPng2Jpg {
316
  $toUnlink[] = $retMain->unlink;
317
  do_action('shortpixel/image/convertpng2jpg_before', $ID, $meta);
318
  //convert to the new URLs the urls in the existing posts.
319
- $baseRelPath = trailingslashit(dirname($image));
 
 
 
 
 
 
320
  $toReplace[self::removeUrlProtocol($imageUrl)] = $baseUrl . $baseRelPath . wp_basename($ret['file']);
321
  $pngSize = $ret['png_size'];
322
  $jpgSize = $ret['jpg_size'];
316
  $toUnlink[] = $retMain->unlink;
317
  do_action('shortpixel/image/convertpng2jpg_before', $ID, $meta);
318
  //convert to the new URLs the urls in the existing posts.
319
+ $baseRelPath = dirname($image);
320
+ // this happens when image does not have a subdir structure like 2021/07
321
+ if ($baseRelPath == '.')
322
+ $baseRelPath = '';
323
+ else
324
+ $baseRelPath = trailingslashit($baseRelPath);
325
+
326
  $toReplace[self::removeUrlProtocol($imageUrl)] = $baseUrl . $baseRelPath . wp_basename($ret['file']);
327
  $pngSize = $ret['png_size'];
328
  $jpgSize = $ret['jpg_size'];
class/wp-short-pixel.php CHANGED
@@ -131,7 +131,7 @@ class WPShortPixel {
131
 
132
  //toolbar notifications
133
  add_action( 'admin_bar_menu', array( &$this, 'toolbar_shortpixel_processing'), 999 );
134
- add_action( 'wp_head', array( $this, 'headCSS')); // for the front-end
135
  //deactivate plugin
136
  add_action( 'admin_post_shortpixel_deactivate_plugin', array(&$this, 'deactivatePlugin'));
137
  //only if the key is not yet valid or the user hasn't bought any credits.
@@ -678,7 +678,7 @@ class WPShortPixel {
678
  if( !is_plugin_active('image-watermark/image-watermark.php')
679
  && !is_plugin_active('amazon-s3-and-cloudfront/wordpress-s3.php')
680
  && !is_plugin_active('amazon-s3-and-cloudfront-pro/amazon-s3-and-cloudfront-pro.php')
681
- && !is_plugin_active('easy-watermark/index.php')) {
682
  try {
683
  $URLsAndPATHs = $this->getURLsAndPATHs($itemHandler);
684
  //send a processing request right after a file was uploaded, do NOT wait for response
@@ -2103,7 +2103,7 @@ class WPShortPixel {
2103
  if ($bkOrigFile && $bkOrigFile->exists())
2104
  $bkOrigFile->move($origFile);
2105
 
2106
- Log::addDebug('Restore result - Backup original file', array($bkOrigFile, $origFile));
2107
  }
2108
  //$this->renameWithRetina($bkFile, $file);
2109
  if (! $bkFile->move($fsFile))
@@ -2175,7 +2175,15 @@ class WPShortPixel {
2175
  $crtMeta['height'] = $height;
2176
  }
2177
  if($png2jpgMain) {
2178
- $crtMeta['file'] = trailingslashit(dirname($crtMeta['file'])) . $fsFile->getFileName();
 
 
 
 
 
 
 
 
2179
  update_attached_file($ID, $crtMeta['file']);
2180
 
2181
  if($png2jpgSizes && count($png2jpgSizes)) {
131
 
132
  //toolbar notifications
133
  add_action( 'admin_bar_menu', array( &$this, 'toolbar_shortpixel_processing'), 999 );
134
+ // add_action( 'wp_head', array( $this, 'headCSS')); // for the front-end
135
  //deactivate plugin
136
  add_action( 'admin_post_shortpixel_deactivate_plugin', array(&$this, 'deactivatePlugin'));
137
  //only if the key is not yet valid or the user hasn't bought any credits.
678
  if( !is_plugin_active('image-watermark/image-watermark.php')
679
  && !is_plugin_active('amazon-s3-and-cloudfront/wordpress-s3.php')
680
  && !is_plugin_active('amazon-s3-and-cloudfront-pro/amazon-s3-and-cloudfront-pro.php')
681
+ && !is_plugin_active('easy-watermark/easy-watermark.php')) {
682
  try {
683
  $URLsAndPATHs = $this->getURLsAndPATHs($itemHandler);
684
  //send a processing request right after a file was uploaded, do NOT wait for response
2103
  if ($bkOrigFile && $bkOrigFile->exists())
2104
  $bkOrigFile->move($origFile);
2105
 
2106
+ Log::addDebug('Restore result - Backup original file', array($bkOrigFile->getFullPath(), $origFile->getFullPath() ));
2107
  }
2108
  //$this->renameWithRetina($bkFile, $file);
2109
  if (! $bkFile->move($fsFile))
2175
  $crtMeta['height'] = $height;
2176
  }
2177
  if($png2jpgMain) {
2178
+
2179
+ $dirname = dirname($crtMeta['file']);
2180
+ if ($dirname == '.')
2181
+ $dirname = '';
2182
+ else
2183
+ $dirname = trailingslashit($dirname);
2184
+
2185
+ $crtMeta['file'] = $dirname . $fsFile->getFileName();
2186
+
2187
  update_attached_file($ID, $crtMeta['file']);
2188
 
2189
  if($png2jpgSizes && count($png2jpgSizes)) {
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: ShortPixel
3
  Tags: convert webp, optimize images, image optimization, resize, compressor, image, avif, compression, optimize, image optimiser, image compression, compress pdf, compress jpg, compress png, performance, photography, smush, scale, pictures
4
  Requires at least: 4.2.0
5
- Tested up to: 5.7
6
  Requires PHP: 5.3
7
- Stable tag: 4.22.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -314,6 +314,15 @@ Alternatively, you can use this filter in your theme's functions.php file:
314
 
315
  == Changelog ==
316
 
 
 
 
 
 
 
 
 
 
317
  = 4.22.2 =
318
  Release date May 12th, 2021
319
  * Fix: the Bulk screen reflects better the extra credits used for WebP and/or AVIF creation;
2
  Contributors: ShortPixel
3
  Tags: convert webp, optimize images, image optimization, resize, compressor, image, avif, compression, optimize, image optimiser, image compression, compress pdf, compress jpg, compress png, performance, photography, smush, scale, pictures
4
  Requires at least: 4.2.0
5
+ Tested up to: 5.8
6
  Requires PHP: 5.3
7
+ Stable tag: 4.22.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
314
 
315
  == Changelog ==
316
 
317
+ = 4.22.3 =
318
+ Release date July 28th, 2021
319
+ * Fix: Error when using WordPress 5.8 Widget editor;
320
+ * Fix: Error when using WP-Offload and WebP image could not be detected;
321
+ * Fix: PNG2JPG when using WP without date directory format would incorrectly add ./ to filename;
322
+ * Fix: Unregistered retina files could throw off optimization;
323
+ * Fix: Easy Watermark plugin changed its main file, so it couldn't be properly detected;
324
+ * Language: 0 new string added, 0 updated, 0 fuzzed, and 0 obsoleted.
325
+
326
  = 4.22.2 =
327
  Release date May 12th, 2021
328
  * Fix: the Bulk screen reflects better the extra credits used for WebP and/or AVIF creation;
shortpixel_api.php CHANGED
@@ -898,6 +898,7 @@ class ShortPixelAPI {
898
 
899
  $itemHandler->updateMeta($meta);
900
  $itemHandler->optimizationSucceeded();
 
901
  Log::addDebug("HANDLE SUCCESS: Metadata saved.");
902
 
903
  if(!$originalSpace) { //das kann nicht sein, alles klar?!
898
 
899
  $itemHandler->updateMeta($meta);
900
  $itemHandler->optimizationSucceeded();
901
+ $itemHandler->deleteItemCache(); // remove cache when done, to prevent re-optimizing things.
902
  Log::addDebug("HANDLE SUCCESS: Metadata saved.");
903
 
904
  if(!$originalSpace) { //das kann nicht sein, alles klar?!
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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.22.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * GitHub Plugin URI: https://github.com/short-pixel-optimizer/shortpixel-image-optimiser
@@ -33,7 +33,7 @@ define('SHORTPIXEL_PLUGIN_DIR', __DIR__);
33
 
34
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
35
 
36
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.22.2");
37
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
38
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
39
  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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.22.3
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * GitHub Plugin URI: https://github.com/short-pixel-optimizer/shortpixel-image-optimiser
33
 
34
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
35
 
36
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.22.3");
37
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
38
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
39
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');