ShortPixel Image Optimizer - Version 4.12.1

Version Description

Release date: 6th November 2018

  • Fix WebP replacement for lazy-loaded images
  • Fix WebP replacement with output buffering on some WP installs
Download this release

Release Info

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

Code changes from version 4.12.0 to 4.12.1

class/front/img-to-picture-webp.php CHANGED
@@ -9,15 +9,15 @@ class ShortPixelImgToPictureWebp {
9
  public static function lazyGet($img, $type) {
10
  return array(
11
  'value' =>
12
- (isset($img[$type]) && strlen($img[$type])) ?
13
- $img[$type]
14
  : (isset($img['data-' . $type]) && strlen($img['data-' . $type]) ?
15
  $img['data-' . $type]
16
- : (isset($img['data-lazy-' . $type]) && strlen($img['data-lazy-' . $type]) ? $img['data-lazy-' . $type] : false)),
17
  'prefix' =>
18
- (isset($img[$type]) && strlen($img[$type])) ? ''
19
  : (isset($img['data-' . $type]) && strlen($img['data-' . $type]) ? 'data-'
20
- : (isset($img['data-lazy-' . $type]) && strlen($img['data-lazy-' . $type]) ? 'data-lazy-' : false))
21
  );
22
  }
23
 
@@ -40,7 +40,7 @@ class ShortPixelImgToPictureWebp {
40
 
41
  $srcsetInfo = self::lazyGet($img, 'srcset');
42
  $srcset = $srcsetInfo['value'];
43
- $srcsetPrefix = $srcsetInfo['prefix'];
44
 
45
  $sizesInfo = self::lazyGet($img, 'sizes');
46
  $sizes = $sizesInfo['value'];
@@ -71,8 +71,10 @@ class ShortPixelImgToPictureWebp {
71
  }
72
  $imageBase = dirname($imageBase) . '/';
73
 
74
- // We don't wanna have an src attribute on the <img>
75
  unset($img['src']);
 
 
76
  //unset($img['srcset']);
77
  //unset($img['sizes']);
78
 
9
  public static function lazyGet($img, $type) {
10
  return array(
11
  'value' =>
12
+ (isset($img['data-lazy-' . $type]) && strlen('data-lazy-' . $img[$type])) ?
13
+ $img['data-lazy-' . $type]
14
  : (isset($img['data-' . $type]) && strlen($img['data-' . $type]) ?
15
  $img['data-' . $type]
16
+ : (isset($img[$type]) && strlen($img[$type]) ? $img[$type] : false)),
17
  'prefix' =>
18
+ (isset($img['data-lazy-' . $type]) && strlen('data-lazy-' . $img[$type])) ? 'data-lazy-'
19
  : (isset($img['data-' . $type]) && strlen($img['data-' . $type]) ? 'data-'
20
+ : (isset($img[$type]) && strlen($img[$type]) ? '' : false))
21
  );
22
  }
23
 
40
 
41
  $srcsetInfo = self::lazyGet($img, 'srcset');
42
  $srcset = $srcsetInfo['value'];
43
+ $srcsetPrefix = $srcset ? $srcsetInfo['prefix'] : $srcInfo['prefix'];
44
 
45
  $sizesInfo = self::lazyGet($img, 'sizes');
46
  $sizes = $sizesInfo['value'];
71
  }
72
  $imageBase = dirname($imageBase) . '/';
73
 
74
+ // We don't wanna have src-ish attributes on the <picture>
75
  unset($img['src']);
76
+ unset($img['data-src']);
77
+ unset($img['data-lazy-src']);
78
  //unset($img['srcset']);
79
  //unset($img['sizes']);
80
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
- Stable tag: 4.12.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -241,6 +241,13 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
 
244
  = 4.12.0 =
245
 
246
  Release date: 31st October 2018
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
+ Stable tag: 4.12.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.12.1 =
245
+
246
+ Release date: 6th November 2018
247
+
248
+ * Fix WebP replacement for lazy-loaded images
249
+ * Fix WebP replacement with output buffering on some WP installs
250
+
251
  = 4.12.0 =
252
 
253
  Release date: 31st October 2018
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.12.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.12.0");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
@@ -179,11 +179,18 @@ function shortPixelGravityForms( $value, $lead, $field, $form ) {
179
  return $value;
180
  }
181
 
 
 
 
 
 
 
182
  if ( get_option('wp-short-pixel-create-webp-markup')) {
183
  //add_filter( 'the_content', 'shortPixelConvertImgToPictureAddWebp', 10000 ); // priority big, so it will be executed last
 
184
  //add_filter( 'post_thumbnail_html', 'shortPixelConvertImgToPictureAddWebp');
185
- ob_start( 'shortPixelConvertImgToPictureAddWebp');
186
  add_action( 'wp_head', 'shortPixelAddPictureJs');
 
187
  // add_action( 'wp_enqueue_scripts', 'spAddPicturefillJs' );
188
  }
189
 
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.12.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.12.1");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
179
  return $value;
180
  }
181
 
182
+ function shortPixelInitOB() {
183
+ if(!is_admin() || (function_exists("wp_doing_ajax") && wp_doing_ajax()) || (defined( 'DOING_AJAX' ) && DOING_AJAX)) {
184
+ ob_start('shortPixelConvertImgToPictureAddWebp');
185
+ }
186
+ }
187
+
188
  if ( get_option('wp-short-pixel-create-webp-markup')) {
189
  //add_filter( 'the_content', 'shortPixelConvertImgToPictureAddWebp', 10000 ); // priority big, so it will be executed last
190
+ //add_filter( 'the_excerpt', 'shortPixelConvertImgToPictureAddWebp', 10000 );
191
  //add_filter( 'post_thumbnail_html', 'shortPixelConvertImgToPictureAddWebp');
 
192
  add_action( 'wp_head', 'shortPixelAddPictureJs');
193
+ add_action( 'init', 'shortPixelInitOB', 1 );
194
  // add_action( 'wp_enqueue_scripts', 'spAddPicturefillJs' );
195
  }
196