EWWW Image Optimizer - Version 5.5.0

Version Description

  • added: GIF to WebP conversion with API and Easy IO
  • changed: plugin removed from disallowed list on WP Engine!
  • changed: disable Lazy Load auto-scale by defining EIO_LL_AUTOSCALE as false
  • fixed: async functions use of wp_die causes empty errors when wp_cron is run from WP-CLI
  • fixed: big image size filter throws error when other plugins run the filter with fewer than 3 parameters
  • fixed: styling broken for optimization info on Nextgen gallery pages
  • fixed: broken link for network admin settings from single-site plugins page
Download this release

Release Info

Developer nosilver4u
Plugin Icon 128x128 EWWW Image Optimizer
Version 5.5.0
Comparing to
See all releases

Code changes from version 5.4.1 to 5.5.0

changelog.txt CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  = 5.4.1 =
2
  * fixed: Bulk Optimizer sticks on stage 2 when there are no images to optimize
3
  * fixed: transparency in PNG images with color type 0 or 2 not detected
1
+ = 5.5.0 =
2
+ * added: GIF to WebP conversion with API and Easy IO
3
+ * changed: plugin removed from disallowed list on WP Engine!
4
+ * changed: disable Lazy Load auto-scale by defining EIO_LL_AUTOSCALE as false
5
+ * fixed: async functions use of wp_die causes empty errors when wp_cron is run from WP-CLI
6
+ * fixed: big image size filter throws error when other plugins run the filter with fewer than 3 parameters
7
+ * fixed: styling broken for optimization info on Nextgen gallery pages
8
+ * fixed: broken link for network admin settings from single-site plugins page
9
+
10
  = 5.4.1 =
11
  * fixed: Bulk Optimizer sticks on stage 2 when there are no images to optimize
12
  * fixed: transparency in PNG images with color type 0 or 2 not detected
classes/class-eio-alt-webp.php CHANGED
@@ -1021,7 +1021,7 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
1021
  if ( ! is_null( $image_path ) && $image_path ) {
1022
  $extension = strtolower( pathinfo( $image_path, PATHINFO_EXTENSION ) );
1023
  }
1024
- if ( $extension && 'gif' === $extension ) {
1025
  return false;
1026
  }
1027
  if ( $extension && 'svg' === $extension ) {
1021
  if ( ! is_null( $image_path ) && $image_path ) {
1022
  $extension = strtolower( pathinfo( $image_path, PATHINFO_EXTENSION ) );
1023
  }
1024
+ if ( $extension && 'gif' === $extension && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ) {
1025
  return false;
1026
  }
1027
  if ( $extension && 'svg' === $extension ) {
classes/class-eio-lazy-load.php CHANGED
@@ -450,7 +450,11 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
450
  $srcset_sizes = $this->get_attribute( $image, 'sizes' );
451
  // Return false on this filter to disable automatic sizes calculation,
452
  // or use the sizes value passed via the filter to conditionally disable it.
453
- if ( false === strpos( $image, 'skip-autoscale' ) && apply_filters( 'eio_lazy_responsive', $srcset_sizes ) ) {
 
 
 
 
454
  $this->set_attribute( $image, 'data-sizes', 'auto', true );
455
  $this->remove_attribute( $image, 'sizes' );
456
  }
@@ -791,6 +795,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
791
  'eio_lazy_vars',
792
  array(
793
  'exactdn_domain' => ( $this->parsing_exactdn ? $this->exactdn_domain : '' ),
 
794
  )
795
  );
796
  }
@@ -813,6 +818,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
813
  'eio_lazy_vars',
814
  array(
815
  'exactdn_domain' => ( $this->parsing_exactdn ? $this->exactdn_domain : '' ),
 
816
  )
817
  );
818
  }
450
  $srcset_sizes = $this->get_attribute( $image, 'sizes' );
451
  // Return false on this filter to disable automatic sizes calculation,
452
  // or use the sizes value passed via the filter to conditionally disable it.
453
+ if (
454
+ false === strpos( $image, 'skip-autoscale' ) &&
455
+ apply_filters( 'eio_lazy_responsive', $srcset_sizes ) &&
456
+ ( ! defined( 'EIO_LL_AUTOSCALE' ) || EIO_LL_AUTOSCALE )
457
+ ) {
458
  $this->set_attribute( $image, 'data-sizes', 'auto', true );
459
  $this->remove_attribute( $image, 'sizes' );
460
  }
795
  'eio_lazy_vars',
796
  array(
797
  'exactdn_domain' => ( $this->parsing_exactdn ? $this->exactdn_domain : '' ),
798
+ 'skip_autoscale' => ( defined( 'EIO_LL_AUTOSCALE' ) ? 1 : 0 ),
799
  )
800
  );
801
  }
818
  'eio_lazy_vars',
819
  array(
820
  'exactdn_domain' => ( $this->parsing_exactdn ? $this->exactdn_domain : '' ),
821
+ 'skip_autoscale' => ( defined( 'EIO_LL_AUTOSCALE' ) ? 1 : 0 ),
822
  )
823
  );
824
  }
classes/class-eio-picture-webp.php CHANGED
@@ -451,7 +451,7 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
451
  if ( ! is_null( $image_path ) && $image_path ) {
452
  $extension = strtolower( pathinfo( $image_path, PATHINFO_EXTENSION ) );
453
  }
454
- if ( $extension && 'gif' === $extension ) {
455
  return false;
456
  }
457
  if ( $extension && 'svg' === $extension ) {
451
  if ( ! is_null( $image_path ) && $image_path ) {
452
  $extension = strtolower( pathinfo( $image_path, PATHINFO_EXTENSION ) );
453
  }
454
+ if ( $extension && 'gif' === $extension && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ) {
455
  return false;
456
  }
457
  if ( $extension && 'svg' === $extension ) {
classes/class-ewww-nextgen.php CHANGED
@@ -346,7 +346,10 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
346
  */
347
  function ewww_ngg_manual_actions_script( $hook ) {
348
  $screen = get_current_screen();
349
- if ( is_null( $screen ) || 'nggallery-manage-images' !== $screen->id ) {
 
 
 
350
  return;
351
  }
352
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) ) {
346
  */
347
  function ewww_ngg_manual_actions_script( $hook ) {
348
  $screen = get_current_screen();
349
+ if ( is_null( $screen ) ) {
350
+ return;
351
+ }
352
+ if ( 'nextgen-gallery_page_nggallery-manage-gallery' !== $screen->id && 'nggallery-manage-images' !== $screen->id ) {
353
  return;
354
  }
355
  if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) ) {
classes/class-ewwwio-background-process.php CHANGED
@@ -173,19 +173,19 @@ if ( ! class_exists( 'EWWWIO_Background_Process' ) ) {
173
 
174
  if ( $this->is_process_running() ) {
175
  // Background process already running.
176
- wp_die();
177
  }
178
 
179
  if ( $this->is_queue_empty() ) {
180
  // No data to process.
181
- wp_die();
182
  }
183
 
184
  check_ajax_referer( $this->identifier, 'nonce' );
185
 
186
  $this->handle();
187
 
188
- wp_die();
189
  }
190
 
191
  /**
@@ -327,7 +327,7 @@ if ( ! class_exists( 'EWWWIO_Background_Process' ) ) {
327
  $this->complete();
328
  }
329
 
330
- wp_die();
331
  }
332
 
333
  /**
173
 
174
  if ( $this->is_process_running() ) {
175
  // Background process already running.
176
+ die;
177
  }
178
 
179
  if ( $this->is_queue_empty() ) {
180
  // No data to process.
181
+ die;
182
  }
183
 
184
  check_ajax_referer( $this->identifier, 'nonce' );
185
 
186
  $this->handle();
187
 
188
+ die;
189
  }
190
 
191
  /**
327
  $this->complete();
328
  }
329
 
330
+ die;
331
  }
332
 
333
  /**
common.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '541.0' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
@@ -178,6 +178,8 @@ add_action( 'wp_head', 'ewww_image_optimizer_resize_detection_script' );
178
  add_action( 'admin_bar_init', 'ewww_image_optimizer_admin_bar_init' );
179
  // Non-AJAX handler to delete the API key, and reroute back to the settings page.
180
  add_action( 'admin_action_ewww_image_optimizer_remove_cloud_key', 'ewww_image_optimizer_remove_cloud_key' );
 
 
181
  // Non-AJAX handler to retest async/background mode.
182
  add_action( 'admin_action_ewww_image_optimizer_retest_background_optimization', 'ewww_image_optimizer_retest_background_optimization' );
183
  // Non-AJAX handler to view the debug log, and display it.
@@ -631,6 +633,11 @@ function ewww_image_optimizer_upgrade() {
631
  if ( get_option( 'ewww_image_optimizer_version' ) < 530 ) {
632
  ewww_image_optimizer_migrate_option_queue_to_table();
633
  }
 
 
 
 
 
634
  if ( get_option( 'ewww_image_optimizer_version' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) ) {
635
  $review_time = rand( time(), time() + 51 * DAY_IN_SECONDS );
636
  add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
@@ -919,6 +926,9 @@ function ewww_image_optimizer_admin_init() {
919
  add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
920
  add_action( 'admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
921
  }
 
 
 
922
  // Prevent ShortPixel AIO messiness.
923
  remove_action( 'admin_notices', 'autoptimizeMain::notice_plug_imgopt' );
924
  if ( class_exists( 'autoptimizeExtra' ) ) {
@@ -2458,7 +2468,7 @@ function ewww_image_optimizer_network_admin_menu() {
2458
  'EWWW Image Optimizer', // Page Title.
2459
  'EWWW Image Optimizer', // Menu title.
2460
  $permissions, // Capability.
2461
- 'ewww-image-optimizer-options', // Slug.
2462
  'ewww_image_optimizer_network_options' // Function to call.
2463
  );
2464
  }
@@ -2638,7 +2648,7 @@ function ewww_image_optimizer_settings_link( $links ) {
2638
  }
2639
  // Load the html for the settings link.
2640
  if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
2641
- $settings_link = '<a href="' . network_admin_url( 'network/settings.php?page=ewww-image-optimizer-options' ) . '">' . esc_html__( 'Settings', 'ewww-image-optimizer' ) . '</a>';
2642
  } else {
2643
  $settings_link = '<a href="' . admin_url( 'options-general.php?page=ewww-image-optimizer-options' ) . '">' . esc_html__( 'Settings', 'ewww-image-optimizer' ) . '</a>';
2644
  }
@@ -3014,7 +3024,7 @@ function ewww_image_optimizer_set_jpg_quality( $quality ) {
3014
  * @param string $file Full path to the uploaded image file.
3015
  * @return int The proper size to use for scaling originals.
3016
  */
3017
- function ewww_image_optimizer_adjust_big_image_threshold( $size, $imagesize, $file ) {
3018
  if ( false !== strpos( $file, 'noresize' ) ) {
3019
  return false;
3020
  }
@@ -4193,6 +4203,9 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
4193
  if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) || ! EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
4194
  $lossy = 0;
4195
  }
 
 
 
4196
  } else {
4197
  $webp = 0;
4198
  }
@@ -9039,10 +9052,10 @@ function ewww_image_optimizer_webp_rewrite_verify() {
9039
  '<IfModule mod_rewrite.c>',
9040
  'RewriteEngine On',
9041
  'RewriteCond %{HTTP_ACCEPT} image/webp',
9042
- 'RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$',
9043
  'RewriteCond %{REQUEST_FILENAME}.webp -f',
9044
  'RewriteCond %{QUERY_STRING} !type=original',
9045
- 'RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_URI}.webp [T=image/webp,E=accept:1,L]',
9046
  '</IfModule>',
9047
  '<IfModule mod_headers.c>',
9048
  'Header append Vary Accept env=REDIRECT_accept',
@@ -9399,6 +9412,7 @@ function ewwwio_debug_info() {
9399
  $webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) ) : '';
9400
  ewwwio_debug_message( $webp_paths );
9401
  ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ? 'on' : 'off' ) );
 
9402
  ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ? 'yes' : 'no' ) );
9403
  if ( ! empty( $_SERVER['SERVER_ADDR'] ) ) {
9404
  ewwwio_debug_message( 'origin: ' . sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) );
@@ -9822,7 +9836,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
9822
  <span style="color: red; font-weight: bolder"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></span>
9823
  <?php endif; ?>
9824
  <?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
9825
- <a target="_blank" href="https://history.exactlywww.com/show/?api_key=' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) . '"><?php esc_html_e( 'View Usage', 'ewww-image-optimizer' ); ?></a>
9826
  <?php endif; ?>
9827
  </p>
9828
  <?php else : ?>
@@ -10695,7 +10709,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
10695
  <noscript><h2><?php esc_html_e( 'WebP', 'ewww-image-optimizer' ); ?></h2></noscript>
10696
  <?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! ewww_image_optimizer_easy_active() ) : ?>
10697
  <p>
10698
- <?php esc_html_e( 'Once JPG/PNG to WebP is enabled, WebP images will be generated for new uploads, but you will need to use the Bulk Optimizer for existing uploads.', 'ewww-image-optimizer' ); ?><br>
10699
  <a href='https://ewww.io/easy/'><?php esc_html_e( 'Get Easy IO for automatic WebP conversion and delivery.', 'ewww-image-optimizer' ); ?></a>
10700
  </p>
10701
  <?php endif; ?>
@@ -10703,12 +10717,12 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
10703
  <?php if ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
10704
  <tr>
10705
  <th scope='row'>
10706
- <label for='ewww_image_optimizer_webp'><?php esc_html_e( 'JPG/PNG to WebP', 'ewww-image-optimizer' ); ?></label>
10707
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
10708
  </th>
10709
  <td>
10710
  <input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ); ?> />
10711
- <span><?php esc_html_e( 'JPG to WebP conversion is lossy, but quality loss is minimal. PNG to WebP conversion is lossless.', 'ewww-image-optimizer' ); ?></span>
10712
  <p class='description'>
10713
  <?php esc_html_e( 'Originals are never deleted, and WebP images should only be served to supported browsers.', 'ewww-image-optimizer' ); ?>
10714
  <a href='#ewww-webp-rewrite'><?php echo esc_html( $rewrite_notice ); ?></a>
@@ -10784,7 +10798,20 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
10784
  </th>
10785
  <td>
10786
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
10787
- <span><?php esc_html_e( 'WebP images will be generated and saved for all JPG/PNG images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
10788
  </td>
10789
  </tr>
10790
  <?php endif; ?>
@@ -10910,10 +10937,10 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
10910
  &lt;IfModule mod_rewrite.c&gt;
10911
  RewriteEngine On
10912
  RewriteCond %{HTTP_ACCEPT} image/webp
10913
- RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
10914
  RewriteCond %{REQUEST_FILENAME}\.webp -f
10915
  RewriteCond %{QUERY_STRING} !type=original
10916
- RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1,L]
10917
  &lt;/IfModule&gt;
10918
  &lt;IfModule mod_headers.c&gt;
10919
  Header append Vary Accept env=REDIRECT_accept
@@ -11143,6 +11170,19 @@ function ewww_image_optimizer_remove_cloud_key( $redirect = true ) {
11143
  }
11144
  }
11145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11146
  /**
11147
  * Loads script to detect scaled images within the page, only enabled for admins.
11148
  */
14
  exit;
15
  }
16
 
17
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '550' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
178
  add_action( 'admin_bar_init', 'ewww_image_optimizer_admin_bar_init' );
179
  // Non-AJAX handler to delete the API key, and reroute back to the settings page.
180
  add_action( 'admin_action_ewww_image_optimizer_remove_cloud_key', 'ewww_image_optimizer_remove_cloud_key' );
181
+ // Non-AJAX handler to enable Force WebP for GIF files.
182
+ add_action( 'admin_action_ewww_image_optimizer_enable_force_gif2webp', 'ewww_image_optimizer_enable_force_gif2webp' );
183
  // Non-AJAX handler to retest async/background mode.
184
  add_action( 'admin_action_ewww_image_optimizer_retest_background_optimization', 'ewww_image_optimizer_retest_background_optimization' );
185
  // Non-AJAX handler to view the debug log, and display it.
633
  if ( get_option( 'ewww_image_optimizer_version' ) < 530 ) {
634
  ewww_image_optimizer_migrate_option_queue_to_table();
635
  }
636
+ if ( get_option( 'ewww_image_optimizer_version' ) < 550 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ) {
637
+ ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', false );
638
+ } elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ) {
639
+ ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', true );
640
+ }
641
  if ( get_option( 'ewww_image_optimizer_version' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) ) {
642
  $review_time = rand( time(), time() + 51 * DAY_IN_SECONDS );
643
  add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
926
  add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
927
  add_action( 'admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
928
  }
929
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
930
+ ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', false );
931
+ }
932
  // Prevent ShortPixel AIO messiness.
933
  remove_action( 'admin_notices', 'autoptimizeMain::notice_plug_imgopt' );
934
  if ( class_exists( 'autoptimizeExtra' ) ) {
2468
  'EWWW Image Optimizer', // Page Title.
2469
  'EWWW Image Optimizer', // Menu title.
2470
  $permissions, // Capability.
2471
+ 'ewww-image-optimizer-options', // Slug.
2472
  'ewww_image_optimizer_network_options' // Function to call.
2473
  );
2474
  }
2648
  }
2649
  // Load the html for the settings link.
2650
  if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
2651
+ $settings_link = '<a href="' . network_admin_url( 'settings.php?page=ewww-image-optimizer-options' ) . '">' . esc_html__( 'Settings', 'ewww-image-optimizer' ) . '</a>';
2652
  } else {
2653
  $settings_link = '<a href="' . admin_url( 'options-general.php?page=ewww-image-optimizer-options' ) . '">' . esc_html__( 'Settings', 'ewww-image-optimizer' ) . '</a>';
2654
  }
3024
  * @param string $file Full path to the uploaded image file.
3025
  * @return int The proper size to use for scaling originals.
3026
  */
3027
+ function ewww_image_optimizer_adjust_big_image_threshold( $size, $imagesize = array(), $file = '' ) {
3028
  if ( false !== strpos( $file, 'noresize' ) ) {
3029
  return false;
3030
  }
4203
  if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) || ! EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
4204
  $lossy = 0;
4205
  }
4206
+ if ( defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_GIF2WEBP' ) && ! EWWW_IMAGE_OPTIMIZER_LOSSY_GIF2WEBP ) {
4207
+ $lossy = 1;
4208
+ }
4209
  } else {
4210
  $webp = 0;
4211
  }
9052
  '<IfModule mod_rewrite.c>',
9053
  'RewriteEngine On',
9054
  'RewriteCond %{HTTP_ACCEPT} image/webp',
9055
+ 'RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$',
9056
  'RewriteCond %{REQUEST_FILENAME}.webp -f',
9057
  'RewriteCond %{QUERY_STRING} !type=original',
9058
+ 'RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_URI}.webp [T=image/webp,E=accept:1,L]',
9059
  '</IfModule>',
9060
  '<IfModule mod_headers.c>',
9061
  'Header append Vary Accept env=REDIRECT_accept',
9412
  $webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) ) : '';
9413
  ewwwio_debug_message( $webp_paths );
9414
  ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ? 'on' : 'off' ) );
9415
+ ewwwio_debug_message( 'forced gif2webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ? 'on' : 'off' ) );
9416
  ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ? 'yes' : 'no' ) );
9417
  if ( ! empty( $_SERVER['SERVER_ADDR'] ) ) {
9418
  ewwwio_debug_message( 'origin: ' . sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) );
9836
  <span style="color: red; font-weight: bolder"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></span>
9837
  <?php endif; ?>
9838
  <?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
9839
+ <a target="_blank" href="https://history.exactlywww.com/show/?api_key=<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ); ?>"><?php esc_html_e( 'View Usage', 'ewww-image-optimizer' ); ?></a>
9840
  <?php endif; ?>
9841
  </p>
9842
  <?php else : ?>
10709
  <noscript><h2><?php esc_html_e( 'WebP', 'ewww-image-optimizer' ); ?></h2></noscript>
10710
  <?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! ewww_image_optimizer_easy_active() ) : ?>
10711
  <p>
10712
+ <?php esc_html_e( 'Once WebP conversion is enabled, WebP images will be generated for new uploads, but you will need to use the Bulk Optimizer for existing uploads.', 'ewww-image-optimizer' ); ?><br>
10713
  <a href='https://ewww.io/easy/'><?php esc_html_e( 'Get Easy IO for automatic WebP conversion and delivery.', 'ewww-image-optimizer' ); ?></a>
10714
  </p>
10715
  <?php endif; ?>
10717
  <?php if ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
10718
  <tr>
10719
  <th scope='row'>
10720
+ <label for='ewww_image_optimizer_webp'><?php esc_html_e( 'WebP Conversion', 'ewww-image-optimizer' ); ?></label>
10721
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
10722
  </th>
10723
  <td>
10724
  <input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ); ?> />
10725
+ <span><?php esc_html_e( 'JPG to WebP conversion is lossy, but quality loss is minimal. PNG/GIF to WebP conversion is lossless.', 'ewww-image-optimizer' ); ?></span>
10726
  <p class='description'>
10727
  <?php esc_html_e( 'Originals are never deleted, and WebP images should only be served to supported browsers.', 'ewww-image-optimizer' ); ?>
10728
  <a href='#ewww-webp-rewrite'><?php echo esc_html( $rewrite_notice ); ?></a>
10798
  </th>
10799
  <td>
10800
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
10801
+ <span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
10802
+ <?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
10803
+ <p>
10804
+ <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
10805
+ <?php esc_html_e( 'Click to enable forced GIF rewriting once WebP version have been generated.', 'ewww-image-optimizer' ); ?>
10806
+ </a>
10807
+ </p>
10808
+ <?php elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
10809
+ <p>
10810
+ <a href="https://optimize.exactlywww.com/api_key/free-trial.php?TB_iframe=true&width=600&height=375" class="thickbox" target="_blank">
10811
+ <?php esc_html_e( 'GIF to WebP conversion requires an API key.', 'ewww-image-optimizer' ); ?>
10812
+ </a>
10813
+ </p>
10814
+ <?php endif; ?>
10815
  </td>
10816
  </tr>
10817
  <?php endif; ?>
10937
  &lt;IfModule mod_rewrite.c&gt;
10938
  RewriteEngine On
10939
  RewriteCond %{HTTP_ACCEPT} image/webp
10940
+ RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$
10941
  RewriteCond %{REQUEST_FILENAME}\.webp -f
10942
  RewriteCond %{QUERY_STRING} !type=original
10943
+ RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1,L]
10944
  &lt;/IfModule&gt;
10945
  &lt;IfModule mod_headers.c&gt;
10946
  Header append Vary Accept env=REDIRECT_accept
11170
  }
11171
  }
11172
 
11173
+ /**
11174
+ * Enables Forced WebP for GIF images once the site is ready.
11175
+ */
11176
+ function ewww_image_optimizer_enable_force_gif2webp() {
11177
+ $permissions = apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' );
11178
+ if ( ! current_user_can( $permissions ) ) {
11179
+ wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
11180
+ }
11181
+ ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', true );
11182
+ wp_safe_redirect( wp_get_referer() );
11183
+ exit;
11184
+ }
11185
+
11186
  /**
11187
  * Loads script to detect scaled images within the page, only enabled for admins.
11188
  */
ewww-image-optimizer.php CHANGED
@@ -13,7 +13,7 @@ Plugin Name: EWWW Image Optimizer
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
- Version: 5.4.1
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
@@ -53,12 +53,6 @@ if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 50600 ) {
53
  require_once( plugin_dir_path( __FILE__ ) . 'classes/class-ewwwio-install-cloud.php' );
54
  // Loads the plugin translations.
55
  add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
56
- } elseif ( defined( 'WPE_PLUGIN_VERSION' ) ) {
57
- add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_wpengine' );
58
- add_action( 'admin_notices', 'ewww_image_optimizer_notice_wpengine' );
59
- require_once( plugin_dir_path( __FILE__ ) . 'classes/class-ewwwio-install-cloud.php' );
60
- // Loads the plugin translations.
61
- add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
62
  } elseif ( defined( 'FLYWHEEL_CONFIG_DIR' ) ) {
63
  add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_flywheel' );
64
  add_action( 'admin_notices', 'ewww_image_optimizer_notice_flywheel' );
@@ -152,14 +146,6 @@ if ( ! function_exists( 'ewww_image_optimizer_unsupported_php' ) ) {
152
  }
153
  }
154
 
155
- /**
156
- * Inform the user that only ewww-image-optimizer-cloud is permitted on WP Engine.
157
- */
158
- function ewww_image_optimizer_notice_wpengine() {
159
- echo "<div id='ewww-image-optimizer-warning-wpengine' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on WP Engine sites. However, the cloud version has been approved by WP Engine. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) .
160
- ' <a href="' . esc_url( admin_url( 'admin.php?action=ewwwio_install_cloud_plugin' ) ) . '">' . esc_html__( 'Install now.', 'ewww-image-optimizer' ) . '</a></p></div>';
161
- }
162
-
163
  /**
164
  * Inform the user that only ewww-image-optimizer-cloud is permitted on Kinsta.
165
  */
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
+ Version: 5.5.0
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
53
  require_once( plugin_dir_path( __FILE__ ) . 'classes/class-ewwwio-install-cloud.php' );
54
  // Loads the plugin translations.
55
  add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
 
 
 
 
 
 
56
  } elseif ( defined( 'FLYWHEEL_CONFIG_DIR' ) ) {
57
  add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_flywheel' );
58
  add_action( 'admin_notices', 'ewww_image_optimizer_notice_flywheel' );
146
  }
147
  }
148
 
 
 
 
 
 
 
 
 
149
  /**
150
  * Inform the user that only ewww-image-optimizer-cloud is permitted on Kinsta.
151
  */
includes/lazysizes-post.js CHANGED
@@ -1,13 +1,19 @@
1
  lazysizesWebP('alpha', lazySizes.init);
2
  function shouldAutoScale(target){
 
 
 
 
3
  if (target.hasAttributes()) {
4
  var attrs = target.attributes
5
  var regNoScale = /skip-autoscale/;
6
  for (var i = attrs.length - 1; i >= 0; i--) {
7
  if (regNoScale.test(attrs[i].name)) {
 
8
  return false;
9
  }
10
  if (regNoScale.test(attrs[i].value)) {
 
11
  return false;
12
  }
13
  }
@@ -135,8 +141,10 @@ document.addEventListener('lazybeforeunveil', function(e){
135
  if (!shouldAutoScale(target)||!shouldAutoScale(target.parentNode)){
136
  var newSrc = false;
137
  } else if ( window.lazySizes.hC(target,'et_pb_jt_filterable_grid_item_image')) {
 
138
  var newSrc = constrainSrc(src,targetWidth,targetHeight,'img-crop');
139
  } else {
 
140
  var newSrc = constrainSrc(src,targetWidth,targetHeight,'img');
141
  }
142
  if (newSrc && src != newSrc){
1
  lazysizesWebP('alpha', lazySizes.init);
2
  function shouldAutoScale(target){
3
+ if (eio_lazy_vars.skip_autoscale == 1) {
4
+ console.log('autoscale disabled globally');
5
+ return false;
6
+ }
7
  if (target.hasAttributes()) {
8
  var attrs = target.attributes
9
  var regNoScale = /skip-autoscale/;
10
  for (var i = attrs.length - 1; i >= 0; i--) {
11
  if (regNoScale.test(attrs[i].name)) {
12
+ console.log('autoscale disabled by attr');
13
  return false;
14
  }
15
  if (regNoScale.test(attrs[i].value)) {
16
+ console.log('autoscale disabled by attr value');
17
  return false;
18
  }
19
  }
141
  if (!shouldAutoScale(target)||!shouldAutoScale(target.parentNode)){
142
  var newSrc = false;
143
  } else if ( window.lazySizes.hC(target,'et_pb_jt_filterable_grid_item_image')) {
144
+ console.log('et filterable grid, using crop');
145
  var newSrc = constrainSrc(src,targetWidth,targetHeight,'img-crop');
146
  } else {
147
+ console.log('plain old img, constraining');
148
  var newSrc = constrainSrc(src,targetWidth,targetHeight,'img');
149
  }
150
  if (newSrc && src != newSrc){
includes/lazysizes.min.js CHANGED
@@ -1 +1 @@
1
- var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var c=r.exec(e);if(c&&t<=c[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var d=c[1]-t;return 20<d||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!c&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],c={},p=Array.prototype.forEach,d=function(e,t){return c[t]||(c[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),c[t].test(e[v]("class")||"")&&c[t]},m=function(e,t){d(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=d(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},b=function(t,a,e){var i=e?o:"removeEventListener";e&&b(t,a),l.forEach(function(e){t[i](e,a)})},w=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},_=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},C=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?u:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},x=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?u(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=u(r,99))}},W=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==C(A.body,"visibility")),$||!("hidden"==C(e.parentNode,"visibility")&&"hidden"==C(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(C(i,"opacity")||1))&&"visible"!=C(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},ce=function(){var e,t,a,i,r,n,o,s,l,c,d,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),c||(c=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=c,d=c*h.expFactor,u=h.hFac,$=null,ie<d&&re<1&&2<ne&&2<H&&!A.hidden?(ie=d,ne=0):ie=1<H&&1<ne&&re<6?c:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(k&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&k&&!i&&re<4&&ne<4&&2<H&&(P[0]||h.preloadAfterLoad)&&(P[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=P[0]||f[t]);i&&!r&&ze(i)}},q=ce,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){u(K)},!0),de=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():u(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),m(t,h.loadedClass),y(t,h.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,c,d;(c=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?m(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),d=e.firesLoad||"src"in t&&(o||n||l),c={target:t},m(t,h.loadingClass),d&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&p.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(t,n):t.src=n),r&&(o||l)&&_(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;d&&!e||(e&&m(t,"ls-is-cached"),ue(c),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&k||!a||!e[v]("src")&&!e.srcset||e.complete||d(e,h.errorClass)||!d(e,h.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=x(function(){h.loadMode=3,de()}),pe=function(){3==h.loadMode&&(h.loadMode=2),ve()},me=function(){k||(n.now()-T<999?u(me,999):(k=!0,h.loadMode=3,de(),e("scroll",pe,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),P=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",de,!0),e("resize",de,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(de).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",de,!0),z[o]("DOMAttrModified",de,!0),setInterval(de,999)),e("hashchange",de,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,de,!0)}),/d$|^c/.test(A.readyState)?me():(e("load",me),A[o]("DOMContentLoaded",de),u(me,2e4)),g.elements.length?(ce(),S._lsFlush()):de()},checkElems:de,unveil:ze,_aLSL:pe}),M=(R=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),f.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||_(e,a.detail)}),L=function(e,t,a){var i,r=e.parentNode;r&&(a=E(e,r,a),(i=w(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&R(e,r,i,a))},Q=x(function(){var e,t=N.length;if(t)for(e=0;e<t;e++)L(N[e])}),{_:function(){N=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:L}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),W._())};var N,R,L,Q;var P,k,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,ce,de,ue,fe,Ae,ge,he,ze,ve,pe,me;var ye,be,we,_e,Ce,Ee,Se;return u(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:W,init:B,uP:_,aC:m,rC:y,hC:d,fire:w,gW:E,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),c=t.getAttribute("data-src-webp");if(ewww_webp_supported&&c&&-1==l.search("webp=1")&&(l=c),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image"))d=constrainSrc(l,o,s,"img-crop");else d=constrainSrc(l,o,s,"img");else var d=!1;d&&l!=d&&t.setAttribute("data-src",d)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(c=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",c)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
1
+ var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(1==eio_lazy_vars.skip_autoscale)return!1;if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var c=r.exec(e);if(c&&t<=c[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var d=c[1]-t;return 20<d||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!c&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],c={},p=Array.prototype.forEach,d=function(e,t){return c[t]||(c[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),c[t].test(e[v]("class")||"")&&c[t]},m=function(e,t){d(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=d(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},b=function(t,a,e){var i=e?o:"removeEventListener";e&&b(t,a),l.forEach(function(e){t[i](e,a)})},w=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},_=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},C=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?u:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},x=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?u(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=u(r,99))}},W=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==C(A.body,"visibility")),$||!("hidden"==C(e.parentNode,"visibility")&&"hidden"==C(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(C(i,"opacity")||1))&&"visible"!=C(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},ce=function(){var e,t,a,i,r,n,o,s,l,c,d,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),c||(c=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=c,d=c*h.expFactor,u=h.hFac,$=null,ie<d&&re<1&&2<ne&&2<H&&!A.hidden?(ie=d,ne=0):ie=1<H&&1<ne&&re<6?c:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(P&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&P&&!i&&re<4&&ne<4&&2<H&&(k[0]||h.preloadAfterLoad)&&(k[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=k[0]||f[t]);i&&!r&&ze(i)}},q=ce,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){u(K)},!0),de=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():u(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),m(t,h.loadedClass),y(t,h.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,c,d;(c=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?m(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),d=e.firesLoad||"src"in t&&(o||n||l),c={target:t},m(t,h.loadingClass),d&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&p.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(t,n):t.src=n),r&&(o||l)&&_(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;d&&!e||(e&&m(t,"ls-is-cached"),ue(c),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&P||!a||!e[v]("src")&&!e.srcset||e.complete||d(e,h.errorClass)||!d(e,h.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=x(function(){h.loadMode=3,de()}),pe=function(){3==h.loadMode&&(h.loadMode=2),ve()},me=function(){P||(n.now()-T<999?u(me,999):(P=!0,h.loadMode=3,de(),e("scroll",pe,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),k=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",de,!0),e("resize",de,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(de).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",de,!0),z[o]("DOMAttrModified",de,!0),setInterval(de,999)),e("hashchange",de,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,de,!0)}),/d$|^c/.test(A.readyState)?me():(e("load",me),A[o]("DOMContentLoaded",de),u(me,2e4)),g.elements.length?(ce(),S._lsFlush()):de()},checkElems:de,unveil:ze,_aLSL:pe}),M=(R=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),f.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||_(e,a.detail)}),L=function(e,t,a){var i,r=e.parentNode;r&&(a=E(e,r,a),(i=w(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&R(e,r,i,a))},Q=x(function(){var e,t=N.length;if(t)for(e=0;e<t;e++)L(N[e])}),{_:function(){N=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:L}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),W._())};var N,R,L,Q;var k,P,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,ce,de,ue,fe,Ae,ge,he,ze,ve,pe,me;var ye,be,we,_e,Ce,Ee,Se;return u(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:W,init:B,uP:_,aC:m,rC:y,hC:d,fire:w,gW:E,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),c=t.getAttribute("data-src-webp");if(ewww_webp_supported&&c&&-1==l.search("webp=1")&&(l=c),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image"))d=constrainSrc(l,o,s,"img-crop");else d=constrainSrc(l,o,s,"img");else var d=!1;d&&l!=d&&t.setAttribute("data-src",d)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(c=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",c)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
5
  Requires at least: 5.0
6
  Tested up to: 5.4
7
  Requires PHP: 5.6
8
- Stable tag: 5.4.1
9
  License: GPLv3
10
 
11
  Speed up your website to better connect with your visitors. Properly compress and size/scale images. Includes lazy load and WebP convert.
@@ -170,9 +170,18 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images
170
 
171
  == Changelog ==
172
 
173
- * Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement
174
  * If you would like to help translate this plugin in your language, get started here: https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/
175
 
 
 
 
 
 
 
 
 
 
176
  = 5.4.1 =
177
  * fixed: Bulk Optimizer sticks on stage 2 when there are no images to optimize
178
  * fixed: transparency in PNG images with color type 0 or 2 not detected
5
  Requires at least: 5.0
6
  Tested up to: 5.4
7
  Requires PHP: 5.6
8
+ Stable tag: 5.5.0
9
  License: GPLv3
10
 
11
  Speed up your website to better connect with your visitors. Properly compress and size/scale images. Includes lazy load and WebP convert.
170
 
171
  == Changelog ==
172
 
173
+ * Feature requests can be viewed and submitted at https://feedback.ewww.io
174
  * If you would like to help translate this plugin in your language, get started here: https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/
175
 
176
+ = 5.5.0 =
177
+ * added: GIF to WebP conversion with API and Easy IO
178
+ * changed: plugin removed from disallowed list on WP Engine!
179
+ * changed: disable Lazy Load auto-scale by defining EIO_LL_AUTOSCALE as false
180
+ * fixed: async functions use of wp_die causes empty errors when wp_cron is run from WP-CLI
181
+ * fixed: big image size filter throws error when other plugins run the filter with fewer than 3 parameters
182
+ * fixed: styling broken for optimization info on Nextgen gallery pages
183
+ * fixed: broken link for network admin settings from single-site plugins page
184
+
185
  = 5.4.1 =
186
  * fixed: Bulk Optimizer sticks on stage 2 when there are no images to optimize
187
  * fixed: transparency in PNG images with color type 0 or 2 not detected
tests/test-optimize.php CHANGED
@@ -426,13 +426,21 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
426
  function test_optimize_gif_10_api() {
427
  update_option( 'ewww_image_optimizer_gif_level', 10 );
428
  update_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
 
429
  update_site_option( 'ewww_image_optimizer_gif_level', 10 );
430
  update_site_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
 
431
  $results = $this->optimize_gif();
 
 
432
  update_option( 'ewww_image_optimizer_cloud_key', '' );
433
  update_site_option( 'ewww_image_optimizer_cloud_key', '' );
434
  $this->assertEquals( 8900, filesize( $results[0] ) );
435
  unlink( $results[0] );
 
 
 
 
436
  }
437
 
438
  /**
426
  function test_optimize_gif_10_api() {
427
  update_option( 'ewww_image_optimizer_gif_level', 10 );
428
  update_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
429
+ update_option( 'ewww_image_optimizer_webp', true );
430
  update_site_option( 'ewww_image_optimizer_gif_level', 10 );
431
  update_site_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
432
+ update_site_option( 'ewww_image_optimizer_webp', true );
433
  $results = $this->optimize_gif();
434
+ update_option( 'ewww_image_optimizer_webp', '' );
435
+ update_site_option( 'ewww_image_optimizer_webp', '' );
436
  update_option( 'ewww_image_optimizer_cloud_key', '' );
437
  update_site_option( 'ewww_image_optimizer_cloud_key', '' );
438
  $this->assertEquals( 8900, filesize( $results[0] ) );
439
  unlink( $results[0] );
440
+ $this->assertEquals( 8014, filesize( $results[0] . '.webp' ) );
441
+ if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
442
+ unlink( $results[0] . '.webp' );
443
+ }
444
  }
445
 
446
  /**
unique.php CHANGED
@@ -44,14 +44,6 @@ function ewww_image_optimizer_cloud_init() {
44
  */
45
  function ewww_image_optimizer_exec_init() {
46
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
47
- // TODO: this one will need to go in favor of the next conditional.
48
- if ( false && defined( 'WPE_PLUGIN_VERSION' ) ) {
49
- add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_wpengine' );
50
- add_action( 'admin_notices', 'ewww_image_optimizer_notice_wpengine' );
51
- if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) ) {
52
- define( 'EWWW_IMAGE_OPTIMIZER_NOEXEC', true );
53
- }
54
- }
55
  global $exactdn;
56
  // If cloud is fully enabled, we're going to skip all the checks related to the bundled tools.
57
  if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
@@ -132,6 +124,7 @@ function ewww_image_optimizer_set_defaults() {
132
  add_option( 'ewww_image_optimizer_optipng_level', 2 );
133
  add_option( 'ewww_image_optimizer_pngout_level', 2 );
134
  add_option( 'ewww_image_optimizer_webp_for_cdn', false );
 
135
  add_option( 'ewww_image_optimizer_picture_webp', false );
136
  add_option( 'ewww_image_optimizer_webp_rewrite_exclude', '' );
137
 
@@ -2147,7 +2140,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2147
  $gquality = null;
2148
  } // End if().
2149
  $compression_level = (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' );
2150
- // Check for previous optimization, so long as the force flag is on and this isn't a new image that needs converting.
2151
  if ( empty( $ewww_force ) && ! ( $new && $convert ) ) {
2152
  $results_msg = ewww_image_optimizer_check_table( $file, $orig_size );
2153
  $smart_reopt = ! empty( $ewww_force_smart ) && ewww_image_optimizer_level_mismatch( $ewww_image->level, $compression_level ) ? true : false;
@@ -2429,11 +2422,9 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2429
  $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, $type, $tools['CWEBP'], $orig_size !== $new_size );
2430
  break;
2431
  case 'image/gif':
2432
- if ( ! empty( $ewww_webp_only ) ) {
2433
- break;
2434
- }
2435
  // If gif2png is turned on, and the image is in the WordPress media library.
2436
  if (
 
2437
  1 === (int) $gallery_type &&
2438
  $fullsize &&
2439
  ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $ewww_convert ) ) &&
@@ -2471,7 +2462,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2471
  }
2472
  }
2473
  $ewww_image->level = $compression_level;
2474
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && 10 === $compression_level ) {
2475
  list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type, $convert, $pngfile, 'image/png', $skip_lossy );
2476
  if ( $converted ) {
2477
  // Check to see if the user wants the originals deleted.
@@ -2481,6 +2472,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2481
  }
2482
  $converted = $filenum;
2483
  $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, 'image/png', null, $orig_size !== $new_size );
 
 
2484
  }
2485
  break;
2486
  }
@@ -2504,7 +2497,9 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2504
  );
2505
  }
2506
  // If gifsicle is disabled.
2507
- if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) ) {
 
 
2508
  $result = __( 'GIF optimization is disabled', 'ewww-image-optimizer' );
2509
  // If utility checking is on, and gifsicle is not installed.
2510
  } elseif ( ! $skip['gifsicle'] && ! $tools['GIFSICLE'] ) {
@@ -2539,6 +2534,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2539
  }
2540
  } elseif ( ! $convert ) {
2541
  // If conversion and optimization are both turned OFF, we are done here.
 
2542
  break;
2543
  }
2544
  // Get the new filesize for the GIF.
@@ -2599,6 +2595,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2599
  }
2600
  }
2601
  } // End if().
 
2602
  break;
2603
  case 'application/pdf':
2604
  if ( ! empty( $ewww_webp_only ) ) {
@@ -2686,7 +2683,7 @@ function ewww_image_optimizer_webp_create( $file, $orig_size, $type, $tool, $rec
2686
  ewwwio_debug_message( 'webp file exists, not forcing or recreating' );
2687
  return esc_html__( 'WebP image already exists.', 'ewww-image-optimizer' );
2688
  }
2689
- if ( empty( $tool ) ) {
2690
  ewww_image_optimizer_cloud_optimizer( $file, $type, false, $webpfile, 'image/webp' );
2691
  } else {
2692
  $nice = '';
44
  */
45
  function ewww_image_optimizer_exec_init() {
46
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
 
 
 
 
 
 
 
 
47
  global $exactdn;
48
  // If cloud is fully enabled, we're going to skip all the checks related to the bundled tools.
49
  if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
124
  add_option( 'ewww_image_optimizer_optipng_level', 2 );
125
  add_option( 'ewww_image_optimizer_pngout_level', 2 );
126
  add_option( 'ewww_image_optimizer_webp_for_cdn', false );
127
+ add_option( 'ewww_image_optimizer_force_gif2webp', false );
128
  add_option( 'ewww_image_optimizer_picture_webp', false );
129
  add_option( 'ewww_image_optimizer_webp_rewrite_exclude', '' );
130
 
2140
  $gquality = null;
2141
  } // End if().
2142
  $compression_level = (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' );
2143
+ // Check for previous optimization, so long as the force flag is not on and this isn't a new image that needs converting.
2144
  if ( empty( $ewww_force ) && ! ( $new && $convert ) ) {
2145
  $results_msg = ewww_image_optimizer_check_table( $file, $orig_size );
2146
  $smart_reopt = ! empty( $ewww_force_smart ) && ewww_image_optimizer_level_mismatch( $ewww_image->level, $compression_level ) ? true : false;
2422
  $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, $type, $tools['CWEBP'], $orig_size !== $new_size );
2423
  break;
2424
  case 'image/gif':
 
 
 
2425
  // If gif2png is turned on, and the image is in the WordPress media library.
2426
  if (
2427
+ empty( $ewww_webp_only ) &&
2428
  1 === (int) $gallery_type &&
2429
  $fullsize &&
2430
  ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $ewww_convert ) ) &&
2462
  }
2463
  }
2464
  $ewww_image->level = $compression_level;
2465
+ if ( empty( $ewww_webp_only ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && 10 === $compression_level ) {
2466
  list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type, $convert, $pngfile, 'image/png', $skip_lossy );
2467
  if ( $converted ) {
2468
  // Check to see if the user wants the originals deleted.
2472
  }
2473
  $converted = $filenum;
2474
  $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, 'image/png', null, $orig_size !== $new_size );
2475
+ } else {
2476
+ $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, $type, null, $orig_size !== $new_size );
2477
  }
2478
  break;
2479
  }
2497
  );
2498
  }
2499
  // If gifsicle is disabled.
2500
+ if ( ! empty( $ewww_webp_only ) ) {
2501
+ $optimize = false;
2502
+ } elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) ) {
2503
  $result = __( 'GIF optimization is disabled', 'ewww-image-optimizer' );
2504
  // If utility checking is on, and gifsicle is not installed.
2505
  } elseif ( ! $skip['gifsicle'] && ! $tools['GIFSICLE'] ) {
2534
  }
2535
  } elseif ( ! $convert ) {
2536
  // If conversion and optimization are both turned OFF, we are done here.
2537
+ $webp_result = ewww_image_optimizer_webp_create( $file, $orig_size, $type, $tools['CWEBP'], $orig_size !== $new_size );
2538
  break;
2539
  }
2540
  // Get the new filesize for the GIF.
2595
  }
2596
  }
2597
  } // End if().
2598
+ $webp_result = ewww_image_optimizer_webp_create( $file, $new_size, $type, $tools['CWEBP'], $orig_size !== $new_size );
2599
  break;
2600
  case 'application/pdf':
2601
  if ( ! empty( $ewww_webp_only ) ) {
2683
  ewwwio_debug_message( 'webp file exists, not forcing or recreating' );
2684
  return esc_html__( 'WebP image already exists.', 'ewww-image-optimizer' );
2685
  }
2686
+ if ( empty( $tool ) || 'image/gif' === $type ) {
2687
  ewww_image_optimizer_cloud_optimizer( $file, $type, false, $webpfile, 'image/webp' );
2688
  } else {
2689
  $nice = '';
vendor/wp-async-request.php CHANGED
@@ -150,7 +150,7 @@ if ( ! class_exists( 'WP_Async_Request' ) ) {
150
 
151
  $this->handle();
152
 
153
- wp_die();
154
  }
155
 
156
  /**
150
 
151
  $this->handle();
152
 
153
+ die;
154
  }
155
 
156
  /**