EWWW Image Optimizer - Version 5.0.0

Version Description

  • added: use native lazy load attributes to supplement lazy loader and make placeholders more efficient
  • added: GCS sub-folder rewriting with ExactDN for cleaner URLs
  • added: option to optimize original versions of scaled images for WP 5.3
  • added: ability to erase optimization history from Tools page
  • changed: define EWWWIO_WPLR_AUTO (any value) to enable auto-optimize on images from WP/LR Sync
  • changed: thumbnails could be converted even if original was not
  • changed: Show Optimized Images table moved to Tools menu
  • fixed: full-size image optimization not deferred if scaled by WP 5.3
  • fixed: data-width and data-height attributes missing when JS WebP active
  • security: rewrote escapeshellarg() wrapper to be more secure
Download this release

Release Info

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

Code changes from version 4.9.3 to 5.0.0

aux-optimize.php CHANGED
@@ -23,52 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
23
  */
24
  function ewww_image_optimizer_aux_images() {
25
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
26
- global $wpdb;
27
  $output = '';
28
- // Find out if the auxiliary image table has anything in it.
29
- $already_optimized = ewww_image_optimizer_aux_images_table_count();
30
- // See if the auxiliary image table needs converting from md5sums to image sizes.
31
- $column = $wpdb->get_row( "SHOW COLUMNS FROM $wpdb->ewwwio_images LIKE 'image_md5'", ARRAY_N );
32
- if ( ! empty( $column ) ) {
33
- ewwwio_debug_message( 'image_md5 column exists, checking for image_md5 values' );
34
- $db_convert = $wpdb->get_results( "SELECT image_md5 FROM $wpdb->ewwwio_images WHERE image_md5 <> ''", ARRAY_N );
35
- }
36
- $output .= '<div id="ewww-aux-forms">';
37
- if ( ! empty( $db_convert ) ) {
38
- $output .= '<p class="ewww-bulk-info">' . esc_html__( 'The database schema has changed, you need to convert to the new format.', 'ewww-image-optimizer' ) . '</p>';
39
- $output .= '<form method="post" id="ewww-aux-convert" class="ewww-bulk-form" action="">';
40
- $output .= wp_nonce_field( 'ewww-image-optimizer-aux-images-convert', 'ewww_wpnonce', true, false );
41
- $output .= '<input type="hidden" name="ewww_convert" value="1">';
42
- $output .= '<button id="ewww-table-convert" type="submit" class="button-secondary action">' . esc_html__( 'Convert Table', 'ewww-image-optimizer' ) . '</button>';
43
- $output .= '</form>';
44
- }
45
- if ( empty( $already_optimized ) ) {
46
- $display = ' style="display:none"';
47
- } else {
48
- $display = '';
49
- }
50
- /* translators: %d: number of images */
51
- $output .= "<p id='ewww-table-info' class='ewww-bulk-info' $display>" . sprintf( esc_html__( 'The plugin keeps track of already optimized images to prevent re-optimization. There are %d images that have been optimized so far.', 'ewww-image-optimizer' ), $already_optimized ) . '</p>';
52
- $output .= "<form id='ewww-show-table' class='ewww-bulk-form' method='post' action='' $display>";
53
- $output .= '<button type="submit" class="button-secondary action">' . esc_html__( 'Show Optimized Images', 'ewww-image-optimizer' ) . '</button>';
54
- $output .= '</form>';
55
- $output .= '<div class="tablenav ewww-aux-table" style="display:none">' .
56
- '<div class="tablenav-pages ewww-aux-table">' .
57
- '<span class="displaying-num ewww-aux-table"></span>' . "\n" .
58
- '<span id="paginator" class="pagination-links ewww-aux-table">' . "\n" .
59
- '<a id="first-images" class="tablenav-pages-navspan button first-page" style="display:none">&laquo;</a>' . "\n" .
60
- '<a id="prev-images" class="tablenav-pages-navspan button prev-page" style="display:none">&lsaquo;</a>' . "\n";
61
- $output .= esc_html__( 'page', 'ewww-image-optimizer' ) . ' <span class="current-page"></span> ' . esc_html__( 'of', 'ewww-image-optimizer' ) . "\n";
62
- $output .= '<span class="total-pages"></span>' . "\n" .
63
- '<a id="next-images" class="tablenav-pages-navspan button next-page" style="display:none">&rsaquo;</a>' . "\n" .
64
- '<a id="last-images" class="tablenav-pages-navspan button last-page" style="display:none">&raquo;</a>' .
65
- '</span>' .
66
- '</div>' .
67
- '</div>' .
68
- '<div id="ewww-bulk-table" class="ewww-aux-table"></div>' .
69
- '<span id="ewww-pointer" style="display:none">0</span>' .
70
- '</div>' .
71
- '</div>';
72
 
73
  $help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
74
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
@@ -138,7 +93,7 @@ function ewww_image_optimizer_aux_images() {
138
  function ewww_image_optimizer_aux_images_table() {
139
  // Verify that an authorized user has called function.
140
  $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
141
- if ( ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk' ) || ! current_user_can( $permissions ) ) {
142
  ewwwio_ob_clean();
143
  die( esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) );
144
  }
@@ -194,7 +149,7 @@ function ewww_image_optimizer_aux_images_table() {
194
  <td><?php echo $type; ?></td>
195
  <td>
196
  <?php echo "$savings <br>$size_string"; ?><br>
197
- <a class="removeimage" onclick="ewwwRemoveImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Remove from table', 'ewww-image-optimizer' ); ?></a>
198
  <?php if ( $optimized_image['backup'] ) { ?>
199
  <br><a class="restoreimage" onclick="ewwwRestoreImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Restore original', 'ewww-image-optimizer' ); ?></a>
200
  <?php } ?>
@@ -217,12 +172,12 @@ function ewww_image_optimizer_aux_images_table() {
217
  }
218
  ?>
219
  id="ewww-image-<?php echo $optimized_image['id']; ?>">
220
- <td style='max-width:50px;' class='column-icon'><img width='50' src="<?php echo $image_url; ?>" /></td>
221
  <td class='title'>...<?php echo $image_name; ?></td>
222
  <td><?php echo $type; ?></td>
223
  <td>
224
  <?php echo "$savings <br>$size_string"; ?><br>
225
- <a class="removeimage" onclick="ewwwRemoveImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Remove from table', 'ewww-image-optimizer' ); ?></a>
226
  <?php if ( $optimized_image['backup'] ) { ?>
227
  <br><a class="restoreimage" onclick="ewwwRestoreImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Restore original', 'ewww-image-optimizer' ); ?></a>
228
  <?php } ?>
@@ -251,7 +206,7 @@ function ewww_image_optimizer_aux_images_table() {
251
  function ewww_image_optimizer_aux_images_remove() {
252
  // Verify that an authorized user has called function.
253
  $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
254
- if ( ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk' ) || ! current_user_can( $permissions ) ) {
255
  ewwwio_ob_clean();
256
  die( esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) );
257
  }
@@ -286,7 +241,7 @@ function ewww_image_optimizer_aux_images_clear_all() {
286
  ewwwio_ob_clean();
287
  global $wpdb;
288
  if ( $wpdb->query( "TRUNCATE $wpdb->ewwwio_images" ) ) {
289
- echo '1';
290
  }
291
  ewwwio_memory( __FUNCTION__ );
292
  die();
@@ -983,5 +938,6 @@ function ewww_image_optimizer_aux_images_cleanup( $auto = false ) {
983
 
984
  add_action( 'wp_ajax_bulk_aux_images_table', 'ewww_image_optimizer_aux_images_table' );
985
  add_action( 'wp_ajax_bulk_aux_images_table_count', 'ewww_image_optimizer_aux_images_table_count' );
 
986
  add_action( 'wp_ajax_bulk_aux_images_remove', 'ewww_image_optimizer_aux_images_remove' );
987
  ?>
23
  */
24
  function ewww_image_optimizer_aux_images() {
25
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
 
26
  $output = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  $help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
29
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
93
  function ewww_image_optimizer_aux_images_table() {
94
  // Verify that an authorized user has called function.
95
  $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
96
+ if ( ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-tools' ) || ! current_user_can( $permissions ) ) {
97
  ewwwio_ob_clean();
98
  die( esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) );
99
  }
149
  <td><?php echo $type; ?></td>
150
  <td>
151
  <?php echo "$savings <br>$size_string"; ?><br>
152
+ <a class="removeimage" onclick="ewwwRemoveImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Remove from history', 'ewww-image-optimizer' ); ?></a>
153
  <?php if ( $optimized_image['backup'] ) { ?>
154
  <br><a class="restoreimage" onclick="ewwwRestoreImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Restore original', 'ewww-image-optimizer' ); ?></a>
155
  <?php } ?>
172
  }
173
  ?>
174
  id="ewww-image-<?php echo $optimized_image['id']; ?>">
175
+ <td style='max-width:50px;' class='column-icon'><img width='50' loading='lazy' src="<?php echo $image_url; ?>" /></td>
176
  <td class='title'>...<?php echo $image_name; ?></td>
177
  <td><?php echo $type; ?></td>
178
  <td>
179
  <?php echo "$savings <br>$size_string"; ?><br>
180
+ <a class="removeimage" onclick="ewwwRemoveImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Remove from history', 'ewww-image-optimizer' ); ?></a>
181
  <?php if ( $optimized_image['backup'] ) { ?>
182
  <br><a class="restoreimage" onclick="ewwwRestoreImage( <?php echo $optimized_image['id']; ?> )"><?php esc_html_e( 'Restore original', 'ewww-image-optimizer' ); ?></a>
183
  <?php } ?>
206
  function ewww_image_optimizer_aux_images_remove() {
207
  // Verify that an authorized user has called function.
208
  $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
209
+ if ( ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-tools' ) || ! current_user_can( $permissions ) ) {
210
  ewwwio_ob_clean();
211
  die( esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) );
212
  }
241
  ewwwio_ob_clean();
242
  global $wpdb;
243
  if ( $wpdb->query( "TRUNCATE $wpdb->ewwwio_images" ) ) {
244
+ die( esc_html__( 'All records have been removed from the optimization history.', 'ewww-image-optimizer' ) );
245
  }
246
  ewwwio_memory( __FUNCTION__ );
247
  die();
938
 
939
  add_action( 'wp_ajax_bulk_aux_images_table', 'ewww_image_optimizer_aux_images_table' );
940
  add_action( 'wp_ajax_bulk_aux_images_table_count', 'ewww_image_optimizer_aux_images_table_count' );
941
+ add_action( 'wp_ajax_bulk_aux_images_table_clear', 'ewww_image_optimizer_aux_images_clear_all' );
942
  add_action( 'wp_ajax_bulk_aux_images_remove', 'ewww_image_optimizer_aux_images_remove' );
943
  ?>
bulk.php CHANGED
@@ -12,23 +12,113 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  }
13
 
14
  /**
15
- * Presents the bulk optimize form and optimization results table.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  */
17
  function ewww_image_optimizer_bulk_preview() {
18
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
19
  ewwwio_debug_version_info();
20
  // Retrieve the attachment IDs that were pre-loaded in the database.
21
- echo '<div class="wrap"><h1>' . esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ) . '</h1>';
22
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' ) ) {
23
  echo '<div class="error"><p>';
24
  esc_html_e( 'Please disable Scheduled optimization before continuing.', 'ewww-image-optimizer' );
25
  echo '</p></div></div>';
26
  return;
27
  }
28
- echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
29
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
30
- echo '<span><a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a></span>';
 
31
  }
 
32
  // Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
33
  $resume = get_option( 'ewww_image_optimizer_bulk_resume' );
34
  if ( empty( $resume ) ) {
@@ -112,7 +202,9 @@ function ewww_image_optimizer_bulk_head_output() {
112
  <form class="ewww-bulk-form" style="border: solid 1px #e5e5e5; background: #fff; padding: 10px;">
113
  <p><label for="ewww-force" style="font-weight: bold"><?php esc_html_e( 'Force re-optimize', 'ewww-image-optimizer' ); ?></label><?php echo ewwwio_help_link( 'https://docs.ewww.io/article/65-force-re-optimization', '5bb640a7042863158cc711cd' ); ?>
114
  &emsp;<input type="checkbox" id="ewww-force" name="ewww-force"<?php echo ( get_transient( 'ewww_image_optimizer_force_reopt' ) ) ? ' checked' : ''; ?>>
115
- &nbsp;<?php esc_html_e( 'Previously optimized images will be skipped by default, check this box before scanning to override.', 'ewww-image-optimizer' ); ?></p>
 
 
116
  <p><label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Choose how long to pause between images (in seconds, 0 = disabled)', 'ewww-image-optimizer' ); ?></label>&emsp;<input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo $delay; ?>"></p>
117
  <div id="ewww-delay-slider" style="margin: 0 0 15px 10px; max-width:500px"></div>
118
  </form>
@@ -847,13 +939,13 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
847
  $skipped_ids[] = $selected_id;
848
  continue;
849
  }
850
- ewww_image_optimizer_debug_log();
851
  $attachment_images['full'] = $file_path;
852
- $retina_path = ewww_image_optimizer_hidpi_optimize( $file_path, true );
 
853
  if ( $retina_path ) {
854
  $attachment_images['full-retina'] = $retina_path;
855
  }
856
- ewww_image_optimizer_debug_log();
857
  // Resized versions available, see what we can find.
858
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
859
  // Meta sizes don't contain a full path, so we calculate one.
@@ -938,6 +1030,16 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
938
  } // End foreach().
939
  } // End if().
940
 
 
 
 
 
 
 
 
 
 
 
941
  ewww_image_optimizer_debug_log();
942
  // Queue sizes from a custom theme.
943
  if ( isset( $meta['image_meta']['resized_images'] ) && ewww_image_optimizer_iterable( $meta['image_meta']['resized_images'] ) ) {
@@ -1666,6 +1768,7 @@ function ewww_image_optimizer_bulk_cleanup() {
1666
  }
1667
 
1668
  add_action( 'admin_enqueue_scripts', 'ewww_image_optimizer_bulk_script' );
 
1669
  add_action( 'wp_ajax_bulk_scan', 'ewww_image_optimizer_media_scan' );
1670
  add_action( 'wp_ajax_bulk_init', 'ewww_image_optimizer_bulk_initialize' );
1671
  add_action( 'wp_ajax_bulk_filename', 'ewww_image_optimizer_bulk_filename' );
12
  }
13
 
14
  /**
15
+ * Presents the tools page and optimization results table.
16
+ */
17
+ function ewww_image_optimizer_display_tools() {
18
+ ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
19
+ echo "<div class='wrap'>\n";
20
+ echo "<h1>EWWW Image Optimizer</h1>\n";
21
+
22
+ // Find out if the auxiliary image table has anything in it.
23
+ $already_optimized = ewww_image_optimizer_aux_images_table_count();
24
+ if ( ! $already_optimized ) {
25
+ esc_html_e( 'Nothing has been optimized yet!', 'ewww-image-optimizer' );
26
+ echo "</div>\n";
27
+ return;
28
+ }
29
+
30
+ $output = '';
31
+ $output .= "<div id='ewww-aux-forms'>\n";
32
+ /* translators: %d: number of images */
33
+ $output .= "<p id='ewww-table-info' class='ewww-tool-info'>" . sprintf( esc_html__( 'The plugin keeps track of already optimized images to prevent re-optimization. There are %d images that have been optimized so far.', 'ewww-image-optimizer' ), $already_optimized ) . "</p>\n";
34
+ $output .= "<form id='ewww-show-table' class='ewww-bulk-form' method='post' action=''>\n";
35
+ $output .= '<button type="submit" class="button-primary action">' . esc_html__( 'Show Optimized Images', 'ewww-image-optimizer' ) . "</button>\n";
36
+ $output .= "</form>\n";
37
+ $output .= "<div class='tablenav ewww-aux-table' style='display:none'>\n" .
38
+ '<div class="tablenav-pages ewww-aux-table">' . "\n" .
39
+ '<span class="displaying-num ewww-aux-table"></span>' . "\n" .
40
+ '<span id="paginator" class="pagination-links ewww-aux-table">' . "\n" .
41
+ '<a id="first-images" class="tablenav-pages-navspan button first-page" style="display:none">&laquo;</a>' . "\n" .
42
+ '<a id="prev-images" class="tablenav-pages-navspan button prev-page" style="display:none">&lsaquo;</a>' . "\n";
43
+ $output .= esc_html__( 'page', 'ewww-image-optimizer' ) . ' <span class="current-page"></span> ' . esc_html__( 'of', 'ewww-image-optimizer' ) . "\n";
44
+ $output .= '<span class="total-pages"></span>' . "\n" .
45
+ '<a id="next-images" class="tablenav-pages-navspan button next-page" style="display:none">&rsaquo;</a>' . "\n" .
46
+ '<a id="last-images" class="tablenav-pages-navspan button last-page" style="display:none">&raquo;</a>' .
47
+ '</span>' . "\n" .
48
+ '</div>' . "\n" .
49
+ '</div>' . "\n" .
50
+ '<div id="ewww-bulk-table" class="ewww-aux-table"></div>' . "\n" .
51
+ '<span id="ewww-pointer" style="display:none">0</span>' . "\n" .
52
+ "</div>\n";
53
+ echo $output;
54
+ echo '<hr>';
55
+ echo "<div>\n<p id='ewww-clear-table-info' class='ewww-tool-info'>" .
56
+ esc_html__( 'The optimization history prevents the plugin from re-optimizing images, but you may erase the history to reduce database size or to force the plugin to re-optimize all images.', 'ewww-image-optimizer' );
57
+ echo "</p>\n";
58
+ echo "<form id='ewww-clear-table' class='ewww-tool-form' method='post' action=''>\n" .
59
+ "<input type='submit' class='button-secondary action' value='" . esc_attr__( 'Erase Optimization History', 'ewww-image-optimizer' ) . "' />\n" .
60
+ "</form>\n</div>\n";
61
+ echo "</div>\n";
62
+ }
63
+
64
+ /**
65
+ * Prepares the javascript functions for the tools page.
66
+ *
67
+ * @param string $hook The Hook suffix of the calling page.
68
+ */
69
+ function ewww_image_optimizer_tool_script( $hook ) {
70
+ ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
71
+ // Make sure we are being called from the bulk optimization page.
72
+ if ( 'tools_page_ewww-image-optimizer-tools' !== $hook ) {
73
+ return;
74
+ }
75
+ wp_enqueue_script( 'ewwwtoolscript', plugins_url( '/includes/eio-tools.js', __FILE__ ), array( 'jquery' ), EWWW_IMAGE_OPTIMIZER_VERSION );
76
+ // Number of images in the ewwwio_table (previously optimized images).
77
+ $image_count = ewww_image_optimizer_aux_images_table_count();
78
+ // Submit a couple variables for our javascript to work with.
79
+ $loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
80
+ $erase_warning = esc_html__( 'Warning: this cannot be undone and will cause a bulk optimize to re-optimize all images.', 'ewww-image-optimizer' );
81
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
82
+ $erase_warning = esc_html__( 'Warning: this cannot be undone. Re-optimizing images will use additional API credits.', 'ewww-image-optimizer' );
83
+ }
84
+ wp_localize_script(
85
+ 'ewwwtoolscript',
86
+ 'ewww_vars',
87
+ array(
88
+ '_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-tools' ),
89
+ 'image_count' => $image_count,
90
+ /* translators: %d: number of images */
91
+ 'count_string' => sprintf( esc_html__( '%d images', 'ewww-image-optimizer' ), $image_count ),
92
+ 'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
93
+ 'original_restored' => esc_html__( 'Original Restored', 'ewww-image-optimizer' ),
94
+ 'restoring' => '<p>' . esc_html__( 'Restoring', 'ewww-image-optimizer' ) . "&nbsp;<img src='$loading_image' /></p>",
95
+ 'erase_warning' => $erase_warning,
96
+ )
97
+ );
98
+ // Load the stylesheet for the jquery progressbar.
99
+ wp_enqueue_style( 'jquery-ui-progressbar', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ) );
100
+ ewwwio_memory( __FUNCTION__ );
101
+ }
102
+
103
+ /**
104
+ * Presents the bulk optimize form.
105
  */
106
  function ewww_image_optimizer_bulk_preview() {
107
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
108
  ewwwio_debug_version_info();
109
  // Retrieve the attachment IDs that were pre-loaded in the database.
110
+ echo '<div class="wrap"><h1 class="wp-heading-inline">' . esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ) . '</h1>';
111
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' ) ) {
112
  echo '<div class="error"><p>';
113
  esc_html_e( 'Please disable Scheduled optimization before continuing.', 'ewww-image-optimizer' );
114
  echo '</p></div></div>';
115
  return;
116
  }
 
117
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
118
+ echo '<a id="ewww-bulk-credits-available" target="_blank" style="margin-left:20px" class="page-title-action" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
119
+ echo '<hr class="wp-header-end">';
120
  }
121
+ echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
122
  // Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
123
  $resume = get_option( 'ewww_image_optimizer_bulk_resume' );
124
  if ( empty( $resume ) ) {
202
  <form class="ewww-bulk-form" style="border: solid 1px #e5e5e5; background: #fff; padding: 10px;">
203
  <p><label for="ewww-force" style="font-weight: bold"><?php esc_html_e( 'Force re-optimize', 'ewww-image-optimizer' ); ?></label><?php echo ewwwio_help_link( 'https://docs.ewww.io/article/65-force-re-optimization', '5bb640a7042863158cc711cd' ); ?>
204
  &emsp;<input type="checkbox" id="ewww-force" name="ewww-force"<?php echo ( get_transient( 'ewww_image_optimizer_force_reopt' ) ) ? ' checked' : ''; ?>>
205
+ &nbsp;<?php esc_html_e( 'Previously optimized images will be skipped by default, check this box before scanning to override.', 'ewww-image-optimizer' ); ?>
206
+ &nbsp;<a href="tools.php?page=ewww-image-optimizer-tools"><?php esc_html_e( 'View optimization history.', 'ewww-image-optimizer' ); ?></a>
207
+ </p>
208
  <p><label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Choose how long to pause between images (in seconds, 0 = disabled)', 'ewww-image-optimizer' ); ?></label>&emsp;<input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo $delay; ?>"></p>
209
  <div id="ewww-delay-slider" style="margin: 0 0 15px 10px; max-width:500px"></div>
210
  </form>
939
  $skipped_ids[] = $selected_id;
940
  continue;
941
  }
 
942
  $attachment_images['full'] = $file_path;
943
+
944
+ $retina_path = ewww_image_optimizer_hidpi_optimize( $file_path, true );
945
  if ( $retina_path ) {
946
  $attachment_images['full-retina'] = $retina_path;
947
  }
948
+
949
  // Resized versions available, see what we can find.
950
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
951
  // Meta sizes don't contain a full path, so we calculate one.
1030
  } // End foreach().
1031
  } // End if().
1032
 
1033
+ // Original image detected.
1034
+ if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
1035
+ ewwwio_debug_message( 'checking for original_image' );
1036
+ // Meta sizes don't contain a path, so we calculate one.
1037
+ $resize_path = trailingslashit( dirname( $file_path ) ) . $meta['original_image'];
1038
+ if ( $remote_file || is_file( $resize_path ) ) {
1039
+ $attachment_images['original_image'] = $resize_path;
1040
+ }
1041
+ }
1042
+
1043
  ewww_image_optimizer_debug_log();
1044
  // Queue sizes from a custom theme.
1045
  if ( isset( $meta['image_meta']['resized_images'] ) && ewww_image_optimizer_iterable( $meta['image_meta']['resized_images'] ) ) {
1768
  }
1769
 
1770
  add_action( 'admin_enqueue_scripts', 'ewww_image_optimizer_bulk_script' );
1771
+ add_action( 'admin_enqueue_scripts', 'ewww_image_optimizer_tool_script' );
1772
  add_action( 'wp_ajax_bulk_scan', 'ewww_image_optimizer_media_scan' );
1773
  add_action( 'wp_ajax_bulk_init', 'ewww_image_optimizer_bulk_initialize' );
1774
  add_action( 'wp_ajax_bulk_filename', 'ewww_image_optimizer_bulk_filename' );
changelog.txt CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 4.9.3 =
2
  * fixed: ExactDN incorrectly scales Elementor background images rather than cropping
3
  * fixed: ExactDN cannot work with Divi/Elementor background images due to use of external CSS files
1
+ = 5.0.0 =
2
+ * added: use native lazy load attributes to supplement lazy loader and make placeholders more efficient
3
+ * added: GCS sub-folder rewriting with ExactDN for cleaner URLs
4
+ * added: option to optimize original versions of scaled images for WP 5.3
5
+ * added: ability to erase optimization history from Tools page
6
+ * changed: define EWWWIO_WPLR_AUTO (any value) to enable auto-optimize on images from WP/LR Sync
7
+ * changed: thumbnails could be converted even if original was not
8
+ * changed: Show Optimized Images table moved to Tools menu
9
+ * fixed: full-size image optimization not deferred if scaled by WP 5.3
10
+ * fixed: data-width and data-height attributes missing when JS WebP active
11
+ * security: rewrote escapeshellarg() wrapper to be more secure
12
+
13
  = 4.9.3 =
14
  * fixed: ExactDN incorrectly scales Elementor background images rather than cropping
15
  * fixed: ExactDN cannot work with Divi/Elementor background images due to use of external CSS files
classes/class-eio-alt-webp.php CHANGED
@@ -111,52 +111,54 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
111
  return $nscript;
112
  }
113
  $attributes = array(
 
114
  'align',
115
  'alt',
116
  'border',
117
- 'crossorigin',
118
- 'height',
119
- 'hspace',
120
- 'ismap',
121
- 'longdesc',
122
- 'usemap',
123
- 'vspace',
124
- 'width',
125
- 'accesskey',
126
  'class',
127
  'contenteditable',
128
  'contextmenu',
 
129
  'dir',
130
  'draggable',
131
  'dropzone',
 
132
  'hidden',
 
133
  'id',
 
134
  'lang',
 
 
135
  'spellcheck',
136
  'style',
137
  'tabindex',
138
  'title',
139
  'translate',
140
- 'sizes',
141
- 'data-caption',
142
- 'data-lazy-type',
143
  'data-attachment-id',
144
- 'data-permalink',
145
- 'data-orig-size',
146
  'data-comments-opened',
147
- 'data-image-meta',
148
- 'data-image-title',
149
- 'data-image-description',
150
  'data-event-trigger',
 
151
  'data-highlight-color',
152
- 'data-highlight-opacity',
153
  'data-highlight-border-color',
154
- 'data-highlight-border-width',
155
  'data-highlight-border-opacity',
156
- 'data-no-lazy',
157
- 'data-lazy',
 
 
 
158
  'data-large_image_width',
159
  'data-large_image_height',
 
 
 
 
 
 
160
  );
161
  foreach ( $attributes as $attribute ) {
162
  $attr_value = $this->get_attribute( $image, $attribute );
111
  return $nscript;
112
  }
113
  $attributes = array(
114
+ 'accesskey',
115
  'align',
116
  'alt',
117
  'border',
 
 
 
 
 
 
 
 
 
118
  'class',
119
  'contenteditable',
120
  'contextmenu',
121
+ 'crossorigin',
122
  'dir',
123
  'draggable',
124
  'dropzone',
125
+ 'height',
126
  'hidden',
127
+ 'hspace',
128
  'id',
129
+ 'ismap',
130
  'lang',
131
+ 'longdesc',
132
+ 'sizes',
133
  'spellcheck',
134
  'style',
135
  'tabindex',
136
  'title',
137
  'translate',
138
+ 'usemap',
139
+ 'vspace',
140
+ 'width',
141
  'data-attachment-id',
142
+ 'data-caption',
 
143
  'data-comments-opened',
 
 
 
144
  'data-event-trigger',
145
+ 'data-height',
146
  'data-highlight-color',
 
147
  'data-highlight-border-color',
 
148
  'data-highlight-border-opacity',
149
+ 'data-highlight-border-width',
150
+ 'data-highlight-opacity',
151
+ 'data-image-meta',
152
+ 'data-image-title',
153
+ 'data-image-description',
154
  'data-large_image_width',
155
  'data-large_image_height',
156
+ 'data-lazy',
157
+ 'data-lazy-type',
158
+ 'data-no-lazy',
159
+ 'data-orig-size',
160
+ 'data-permalink',
161
+ 'data-width',
162
  );
163
  foreach ( $attributes as $attribute ) {
164
  $attr_value = $this->get_attribute( $image, $attribute );
classes/class-eio-lazy-load.php CHANGED
@@ -298,6 +298,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
298
  } else {
299
  $this->set_attribute( $image, 'src', $placeholder_src, true );
300
  }
 
301
  $this->set_attribute( $image, 'class', $this->get_attribute( $image, 'class' ) . ' lazyload', true );
302
  $buffer = str_replace( $orig_img, $image . $noscript, $buffer );
303
  }
298
  } else {
299
  $this->set_attribute( $image, 'src', $placeholder_src, true );
300
  }
301
+ $this->set_attribute( $image, 'loading', 'lazy' );
302
  $this->set_attribute( $image, 'class', $this->get_attribute( $image, 'class' ) . ' lazyload', true );
303
  $buffer = str_replace( $orig_img, $image . $noscript, $buffer );
304
  }
classes/class-ewwwio-tracking.php CHANGED
@@ -141,6 +141,7 @@ class EWWWIO_Tracking {
141
  $data['background_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' );
142
  $data['scheduled_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' );
143
  $data['include_media_folders'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' );
 
144
  $data['folders_to_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' );
145
  $data['folders_to_ignore'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_exclude_paths' );
146
  $data['resize_media_width'] = (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
141
  $data['background_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' );
142
  $data['scheduled_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' );
143
  $data['include_media_folders'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' );
144
+ $data['include_originals'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' );
145
  $data['folders_to_opt'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' );
146
  $data['folders_to_ignore'] = (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_exclude_paths' );
147
  $data['resize_media_width'] = (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
classes/class-exactdn.php CHANGED
@@ -184,9 +184,12 @@ if ( ! class_exists( 'ExactDN' ) ) {
184
  global $as3cf;
185
  $s3_region = $as3cf->get_setting( 'region' );
186
  $s3_bucket = $as3cf->get_setting( 'bucket' );
 
 
 
187
  $s3_domain = $as3cf->get_provider()->get_url_domain( $s3_bucket, $s3_region, null, array(), true );
188
  $this->debug_message( "found S3 domain of $s3_domain with bucket $s3_bucket and region $s3_region" );
189
- if ( ! empty( $s3_domain ) ) {
190
  $s3_active = true;
191
  }
192
  }
@@ -204,7 +207,10 @@ if ( ! class_exists( 'ExactDN' ) ) {
204
  }
205
  $this->upload_domain = $upload_url_parts['host'];
206
  $this->debug_message( "allowing images from here: $this->upload_domain" );
207
- if ( strpos( $this->upload_domain, 'amazonaws.com' ) && ! empty( $upload_url_parts['path'] ) ) {
 
 
 
208
  $this->remove_path = rtrim( $upload_url_parts['path'], '/' );
209
  $this->debug_message( "removing this from urls: $this->remove_path" );
210
  }
@@ -273,9 +279,12 @@ if ( ! class_exists( 'ExactDN' ) ) {
273
  $s3_scheme = $as3cf->get_url_scheme();
274
  $s3_region = $as3cf->get_setting( 'region' );
275
  $s3_bucket = $as3cf->get_setting( 'bucket' );
 
 
 
276
  $s3_domain = $as3cf->get_provider()->get_url_domain( $s3_bucket, $s3_region, null, array(), true );
277
  $this->debug_message( "found S3 domain of $s3_domain with bucket $s3_bucket and region $s3_region" );
278
- if ( ! empty( $s3_domain ) ) {
279
  $s3_active = true;
280
  }
281
  }
@@ -310,7 +319,11 @@ if ( ! class_exists( 'ExactDN' ) ) {
310
  } elseif ( ! empty( $result['body'] ) && strpos( $result['body'], 'domain' ) !== false ) {
311
  $response = json_decode( $result['body'], true );
312
  if ( ! empty( $response['domain'] ) ) {
313
- if ( strpos( $site_url, 'amazonaws.com' ) || strpos( $site_url, 'digitaloceanspaces.com' ) ) {
 
 
 
 
314
  $this->set_exactdn_option( 'verify_method', -1, false );
315
  }
316
  if ( get_option( 'exactdn_never_been_active' ) ) {
@@ -375,7 +388,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
375
  add_action( 'admin_notices', $this->prefix . 'notice_exactdn_activation_error' );
376
  return false;
377
  } elseif ( ! empty( $test_result['body'] ) && strlen( $test_result['body'] ) > 300 ) {
378
- if ( 200 === $test_result['response']['code'] &&
379
  ( '89504e470d0a1a0a' === bin2hex( substr( $test_result['body'], 0, 8 ) ) || '52494646' === bin2hex( substr( $test_result['body'], 0, 4 ) ) ) ) {
380
  $this->debug_message( 'exactdn (real-world) verification succeeded' );
381
  $this->set_exactdn_option( 'verified', 1, false );
@@ -385,6 +398,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
385
  $this->debug_message( 'mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
386
  $exactdn_activate_error = 'zone setup pending';
387
  }
 
 
 
388
  add_action( 'admin_notices', $this->prefix . 'notice_exactdn_activation_error' );
389
  return false;
390
  }
@@ -793,7 +809,8 @@ if ( ! class_exists( 'ExactDN' ) ) {
793
  '/' === substr( $src, 0, 1 ) &&
794
  '/' !== substr( $src, 1, 1 ) &&
795
  false === strpos( $this->upload_domain, 'amazonaws.com' ) &&
796
- false === strpos( $this->upload_domain, 'digitaloceanspaces.com' )
 
797
  ) {
798
  $src = '//' . $this->upload_domain . $src;
799
  }
@@ -1143,7 +1160,11 @@ if ( ! class_exists( 'ExactDN' ) ) {
1143
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/wp-content/([^"\'?>]+?)\.(htm|html|php|ashx|m4v|mov|wvm|qt|webm|ogv|mp4|m4p|mpg|mpeg|mpv)#i', '$1//' . $this->upload_domain . '$2/?wpcontent-bypass?/$3.$4', $content );
1144
  $content = str_replace( 'wp-content/themes/jupiter"', '?wpcontent-bypass?/themes/jupiter"', $content );
1145
  $content = str_replace( 'wp-content/plugins/anti-captcha/', '?wpcontent-bypass?/plugins/anti-captcha', $content );
1146
- if ( strpos( $this->upload_domain, 'amazonaws.com' ) || strpos( $this->upload_domain, 'digitaloceanspaces.com' ) ) {
 
 
 
 
1147
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i', '$1//' . $this->exactdn_domain . '/', $content );
1148
  } else {
1149
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?>]+?)?(nextgen-image|wp-includes|wp-content)/#i', '$1//' . $this->exactdn_domain . '/$2$3/', $content );
184
  global $as3cf;
185
  $s3_region = $as3cf->get_setting( 'region' );
186
  $s3_bucket = $as3cf->get_setting( 'bucket' );
187
+ if ( is_wp_error( $s3_region ) ) {
188
+ $s3_region = '';
189
+ }
190
  $s3_domain = $as3cf->get_provider()->get_url_domain( $s3_bucket, $s3_region, null, array(), true );
191
  $this->debug_message( "found S3 domain of $s3_domain with bucket $s3_bucket and region $s3_region" );
192
+ if ( ! empty( $s3_domain ) && $as3cf->get_setting( 'serve-from-s3' ) ) {
193
  $s3_active = true;
194
  }
195
  }
207
  }
208
  $this->upload_domain = $upload_url_parts['host'];
209
  $this->debug_message( "allowing images from here: $this->upload_domain" );
210
+ if (
211
+ ( false !== strpos( $this->upload_domain, 'amazonaws.com' ) || false !== strpos( $this->upload_domain, 'storage.googleapis.com' ) ) &&
212
+ ! empty( $upload_url_parts['path'] )
213
+ ) {
214
  $this->remove_path = rtrim( $upload_url_parts['path'], '/' );
215
  $this->debug_message( "removing this from urls: $this->remove_path" );
216
  }
279
  $s3_scheme = $as3cf->get_url_scheme();
280
  $s3_region = $as3cf->get_setting( 'region' );
281
  $s3_bucket = $as3cf->get_setting( 'bucket' );
282
+ if ( is_wp_error( $s3_region ) ) {
283
+ $s3_region = '';
284
+ }
285
  $s3_domain = $as3cf->get_provider()->get_url_domain( $s3_bucket, $s3_region, null, array(), true );
286
  $this->debug_message( "found S3 domain of $s3_domain with bucket $s3_bucket and region $s3_region" );
287
+ if ( ! empty( $s3_domain ) && $as3cf->get_setting( 'serve-from-s3' ) ) {
288
  $s3_active = true;
289
  }
290
  }
319
  } elseif ( ! empty( $result['body'] ) && strpos( $result['body'], 'domain' ) !== false ) {
320
  $response = json_decode( $result['body'], true );
321
  if ( ! empty( $response['domain'] ) ) {
322
+ if (
323
+ false !== strpos( $site_url, 'amazonaws.com' ) ||
324
+ false !== strpos( $site_url, 'digitaloceanspaces.com' ) ||
325
+ false !== strpos( $site_url, 'storage.googleapis.com' )
326
+ ) {
327
  $this->set_exactdn_option( 'verify_method', -1, false );
328
  }
329
  if ( get_option( 'exactdn_never_been_active' ) ) {
388
  add_action( 'admin_notices', $this->prefix . 'notice_exactdn_activation_error' );
389
  return false;
390
  } elseif ( ! empty( $test_result['body'] ) && strlen( $test_result['body'] ) > 300 ) {
391
+ if ( 200 === (int) $test_result['response']['code'] &&
392
  ( '89504e470d0a1a0a' === bin2hex( substr( $test_result['body'], 0, 8 ) ) || '52494646' === bin2hex( substr( $test_result['body'], 0, 4 ) ) ) ) {
393
  $this->debug_message( 'exactdn (real-world) verification succeeded' );
394
  $this->set_exactdn_option( 'verified', 1, false );
398
  $this->debug_message( 'mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
399
  $exactdn_activate_error = 'zone setup pending';
400
  }
401
+ if ( ! empty( $test_result['response']['code'] ) && 200 !== (int) $test_result['response']['code'] ) {
402
+ ewwwio_debug_message( 'received response code: ' . $test_result['response']['code'] );
403
+ }
404
  add_action( 'admin_notices', $this->prefix . 'notice_exactdn_activation_error' );
405
  return false;
406
  }
809
  '/' === substr( $src, 0, 1 ) &&
810
  '/' !== substr( $src, 1, 1 ) &&
811
  false === strpos( $this->upload_domain, 'amazonaws.com' ) &&
812
+ false === strpos( $this->upload_domain, 'digitaloceanspaces.com' ) &&
813
+ false === strpos( $this->upload_domain, 'storage.googleapis.com' )
814
  ) {
815
  $src = '//' . $this->upload_domain . $src;
816
  }
1160
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/wp-content/([^"\'?>]+?)\.(htm|html|php|ashx|m4v|mov|wvm|qt|webm|ogv|mp4|m4p|mpg|mpeg|mpv)#i', '$1//' . $this->upload_domain . '$2/?wpcontent-bypass?/$3.$4', $content );
1161
  $content = str_replace( 'wp-content/themes/jupiter"', '?wpcontent-bypass?/themes/jupiter"', $content );
1162
  $content = str_replace( 'wp-content/plugins/anti-captcha/', '?wpcontent-bypass?/plugins/anti-captcha', $content );
1163
+ if (
1164
+ false !== strpos( $this->upload_domain, 'amazonaws.com' ) ||
1165
+ false !== strpos( $this->upload_domain, 'digitaloceanspaces.com' ) ||
1166
+ false !== strpos( $this->upload_domain, 'storage.googleapis.com' )
1167
+ ) {
1168
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i', '$1//' . $this->exactdn_domain . '/', $content );
1169
  } else {
1170
  $content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?>]+?)?(nextgen-image|wp-includes|wp-content)/#i', '$1//' . $this->exactdn_domain . '/$2$3/', $content );
common.php CHANGED
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
22
  exit;
23
  }
24
 
25
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '493.0' );
26
 
27
  // Initialize a couple globals.
28
  $eio_debug = '';
@@ -66,6 +66,8 @@ if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_noauto' ) ) {
66
  if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_DISABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_DISABLE_EDITOR ) {
67
  // Turns off the ewwwio_image_editor during uploads.
68
  add_action( 'add_attachment', 'ewww_image_optimizer_add_attachment' );
 
 
69
  // Turns off ewwwio_image_editor during Enable Media Replace.
70
  add_filter( 'emr_unfiltered_get_attached_file', 'ewww_image_optimizer_image_sizes' );
71
  // Checks to see if thumb regen or other similar operation is running via REST API.
@@ -538,12 +540,11 @@ function ewww_image_optimizer_init() {
538
  }
539
  }
540
  }
541
- if ( defined( 'DOING_WPLR_REQUEST' ) && DOING_WPLR_REQUEST ) {
542
  // Unhook all automatic processing, and save an option that (does not autoload) tells the user LR Sync regenerated their images and they should run the bulk optimizer.
543
  remove_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
544
  remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
545
  add_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_lr_sync_update' );
546
- return;
547
  }
548
  }
549
 
@@ -760,6 +761,8 @@ function ewww_image_optimizer_admin_init() {
760
  update_site_option( 'ewww_image_optimizer_parallel_optimization', $_POST['ewww_image_optimizer_parallel_optimization'] );
761
  $_POST['ewww_image_optimizer_include_media_paths'] = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
762
  update_site_option( 'ewww_image_optimizer_include_media_paths', $_POST['ewww_image_optimizer_include_media_paths'] );
 
 
763
  $_POST['ewww_image_optimizer_webp_for_cdn'] = ( empty( $_POST['ewww_image_optimizer_webp_for_cdn'] ) ? false : true );
764
  update_site_option( 'ewww_image_optimizer_webp_for_cdn', $_POST['ewww_image_optimizer_webp_for_cdn'] );
765
  $_POST['ewww_image_optimizer_webp_force'] = ( empty( $_POST['ewww_image_optimizer_webp_force'] ) ? false : true );
@@ -813,6 +816,7 @@ function ewww_image_optimizer_admin_init() {
813
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
814
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
815
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
 
816
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
817
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
818
  global $ewwwio_tracking;
@@ -2246,19 +2250,26 @@ function ewww_image_optimizer_resize_dup_check() {
2246
  * Adds various items to the admin menu.
2247
  */
2248
  function ewww_image_optimizer_admin_menu() {
2249
- $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
2250
  // Adds bulk optimize to the media library menu.
2251
- $ewww_bulk_page = add_media_page( esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ), esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ), $permissions, 'ewww-image-optimizer-bulk', 'ewww_image_optimizer_bulk_preview' );
2252
- // TEST TODO: move this to a unit test or something!
2253
- /* add_media_page( esc_html__( 'Resize checker', 'ewww-image-optimizer' ), esc_html__( 'Duplicate Resize Check', 'ewww-image-optimizer' ), $permissions, 'ewww-image-optimizer-resize-dup-check', 'ewww_image_optimizer_resize_dup_check' ); */
2254
- $ewww_webp_migrate_page = add_submenu_page( null, esc_html__( 'Migrate WebP Images', 'ewww-image-optimizer' ), esc_html__( 'Migrate WebP Images', 'ewww-image-optimizer' ), $permissions, 'ewww-image-optimizer-webp-migrate', 'ewww_image_optimizer_webp_migrate_preview' );
 
 
 
 
 
 
 
 
2255
  if ( ! function_exists( 'is_plugin_active' ) ) {
2256
  // Need to include the plugin library for the is_plugin_active function.
2257
  require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
2258
  }
2259
  if ( ! is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
2260
  // Add options page to the settings menu.
2261
- $ewww_options_page = add_options_page(
2262
  'EWWW Image Optimizer', // Page title.
2263
  'EWWW Image Optimizer', // Menu title.
2264
  apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability.
@@ -2267,7 +2278,7 @@ function ewww_image_optimizer_admin_menu() {
2267
  );
2268
  } else {
2269
  // Add options page to the single-site settings menu.
2270
- $ewww_options_page = add_options_page(
2271
  'EWWW Image Optimizer', // Page title.
2272
  'EWWW Image Optimizer', // Menu title.
2273
  apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability.
@@ -2720,22 +2731,6 @@ function ewww_image_optimizer_webp_paths_sanitize( $paths ) {
2720
  return $paths_saved;
2721
  }
2722
 
2723
- /**
2724
- * Replacement for escapeshellarg() that won't kill non-ASCII characters.
2725
- *
2726
- * @param string $arg A value to sanitize/escape for commmand-line usage.
2727
- * @return string The value after being escaped.
2728
- */
2729
- function ewww_image_optimizer_escapeshellarg( $arg ) {
2730
- if ( PHP_OS === 'WINNT' ) {
2731
- $safe_arg = '"' . $arg . '"';
2732
- } else {
2733
- $safe_arg = "'" . str_replace( "'", "'\"'\"'", $arg ) . "'";
2734
- }
2735
- ewwwio_memory( __FUNCTION__ );
2736
- return $safe_arg;
2737
- }
2738
-
2739
  /**
2740
  * Retrieves/sanitizes jpg background fill setting or returns null for png2jpg conversions.
2741
  *
@@ -3018,7 +3013,7 @@ function ewww_image_optimizer_cloud_restore_single_image_handler() {
3018
  ewwwio_ob_clean();
3019
  wp_die( ewwwio_json_encode( array( 'error' => esc_html__( 'No image ID was provided.', 'ewww-image-optimizer' ) ) ) );
3020
  }
3021
- if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk' ) ) {
3022
  ewwwio_ob_clean();
3023
  wp_die( ewwwio_json_encode( array( 'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) ) ) );
3024
  }
@@ -6024,6 +6019,21 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
6024
  } // End foreach().
6025
  } // End if().
6026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6027
  // Process size from a custom theme.
6028
  if ( isset( $meta['image_meta']['resized_images'] ) && ewww_image_optimizer_iterable( $meta['image_meta']['resized_images'] ) ) {
6029
  $imagemeta_resize_pathinfo = pathinfo( $file_path );
@@ -7032,7 +7042,10 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null, $r
7032
  // Give the user the option to optimize the image right now.
7033
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
7034
  $sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
7035
- $output .= '<div>' . sprintf(
 
 
 
7036
  esc_html(
7037
  /* translators: %d: The number of resize/thumbnail images */
7038
  _n( '%d size to compress', '%d sizes to compress', $sizes_to_opt, 'ewww-image-optimizer' )
@@ -7120,7 +7133,10 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null, $r
7120
  // Otherwise, this must be an image we haven't processed.
7121
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
7122
  $sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
7123
- $output .= '<div>' . sprintf(
 
 
 
7124
  esc_html(
7125
  /* translators: %d: The number of resize/thumbnail images */
7126
  _n( '%d size to compress', '%d sizes to compress', $sizes_to_opt, 'ewww-image-optimizer' )
@@ -8089,11 +8105,12 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8089
  esc_html__( 'New images uploaded to the Media Library will be optimized automatically. If you have existing images you would like to optimize, you can use the %s tool.', 'ewww-image-optimizer' ),
8090
  $bulk_link
8091
  ) . ewwwio_help_link( 'https://docs.ewww.io/article/4-getting-started', '5853713bc697912ffd6c0b98' ) . ' ' .
 
8092
  sprintf(
8093
  /* translators: %s: S3 Image Optimizer (link) */
8094
  esc_html__( 'Images stored in an Amazon S3 bucket can be optimized using our %s.' ),
8095
  $s3_link
8096
- ) .
8097
  "</p>\n";
8098
 
8099
  $compress_score = 0;
@@ -8400,6 +8417,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8400
  '</div><!-- end .ewww-guage -->';
8401
  $status_output .= $savings_guage;
8402
  $status_output .= '<p style="text-align:center"><strong>' . esc_html__( 'Savings', 'ewww-image-optimizer' ) . '</strong></p>';
 
 
 
8403
  $status_output .= '</div><!-- end .ewww-status-detail --></li>';
8404
  }
8405
  ewwwio_debug_message( ewww_image_optimizer_aux_images_table_count() . ' images have been optimized' );
@@ -8648,8 +8668,20 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8648
  $output[] = "<tr class='$network_class'><th>&nbsp;</th><td>" .
8649
  '<p><span style="color: #3eadc9">' . esc_html__( '*Include Media Library Folders has been disabled because it will cause the scanner to ignore the disabled resizes.', 'ewww-image-optimizer' ) . "</span></p></td></tr>\n";
8650
  }
8651
- $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_include_media_paths'>" . esc_html__( 'Include Media Folders', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,5853713bc697912ffd6c0b98' ) . "</th><td><input type='checkbox' id='ewww_image_optimizer_include_media_paths' name='ewww_image_optimizer_include_media_paths' $media_include_disable value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) && ! get_option( 'ewww_image_optimizer_disable_resizes_opt' ) ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'Scan all images from the latest two folders of the Media Library during the Bulk Optimizer and Scheduled Optimization.', 'ewww-image-optimizer' ) . "</td></tr>\n";
 
 
 
 
 
8652
  ewwwio_debug_message( 'include media library: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) ? 'on' : 'off' ) );
 
 
 
 
 
 
 
8653
  $aux_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' ) ) ) : '';
8654
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_aux_paths'>" . esc_html__( 'Folders to Optimize', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,5853713bc697912ffd6c0b98' ) . '</th><td>' .
8655
  /* translators: %s: the folder where WordPress is installed */
22
  exit;
23
  }
24
 
25
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '500.0' );
26
 
27
  // Initialize a couple globals.
28
  $eio_debug = '';
66
  if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_DISABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_DISABLE_EDITOR ) {
67
  // Turns off the ewwwio_image_editor during uploads.
68
  add_action( 'add_attachment', 'ewww_image_optimizer_add_attachment' );
69
+ // Turn off the editor when scaling down the original (core WP 5.3+).
70
+ add_filter( 'big_image_size_threshold', 'ewww_image_optimizer_image_sizes' );
71
  // Turns off ewwwio_image_editor during Enable Media Replace.
72
  add_filter( 'emr_unfiltered_get_attached_file', 'ewww_image_optimizer_image_sizes' );
73
  // Checks to see if thumb regen or other similar operation is running via REST API.
540
  }
541
  }
542
  }
543
+ if ( defined( 'DOING_WPLR_REQUEST' ) && DOING_WPLR_REQUEST && ! defined( 'EWWWIO_WPLR_AUTO' ) ) {
544
  // Unhook all automatic processing, and save an option that (does not autoload) tells the user LR Sync regenerated their images and they should run the bulk optimizer.
545
  remove_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
546
  remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
547
  add_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_lr_sync_update' );
 
548
  }
549
  }
550
 
761
  update_site_option( 'ewww_image_optimizer_parallel_optimization', $_POST['ewww_image_optimizer_parallel_optimization'] );
762
  $_POST['ewww_image_optimizer_include_media_paths'] = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
763
  update_site_option( 'ewww_image_optimizer_include_media_paths', $_POST['ewww_image_optimizer_include_media_paths'] );
764
+ $_POST['ewww_image_optimizer_include_originals'] = ( empty( $_POST['ewww_image_optimizer_include_originals'] ) ? false : true );
765
+ update_site_option( 'ewww_image_optimizer_include_originals', $_POST['ewww_image_optimizer_include_originals'] );
766
  $_POST['ewww_image_optimizer_webp_for_cdn'] = ( empty( $_POST['ewww_image_optimizer_webp_for_cdn'] ) ? false : true );
767
  update_site_option( 'ewww_image_optimizer_webp_for_cdn', $_POST['ewww_image_optimizer_webp_for_cdn'] );
768
  $_POST['ewww_image_optimizer_webp_force'] = ( empty( $_POST['ewww_image_optimizer_webp_force'] ) ? false : true );
816
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
817
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
818
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
819
+ register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_originals', 'boolval' );
820
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
821
  register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
822
  global $ewwwio_tracking;
2250
  * Adds various items to the admin menu.
2251
  */
2252
  function ewww_image_optimizer_admin_menu() {
 
2253
  // Adds bulk optimize to the media library menu.
2254
+ $permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
2255
+ add_media_page( esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ), esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ), $permissions, 'ewww-image-optimizer-bulk', 'ewww_image_optimizer_bulk_preview' );
2256
+ add_submenu_page( null, esc_html__( 'Migrate WebP Images', 'ewww-image-optimizer' ), esc_html__( 'Migrate WebP Images', 'ewww-image-optimizer' ), $permissions, 'ewww-image-optimizer-webp-migrate', 'ewww_image_optimizer_webp_migrate_preview' );
2257
+
2258
+ // Add tools page.
2259
+ add_management_page(
2260
+ 'EWWW Image Optimizer', // Page title.
2261
+ 'EWWW Image Optimizer', // Menu title.
2262
+ apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability.
2263
+ 'ewww-image-optimizer-tools', // Slug.
2264
+ 'ewww_image_optimizer_display_tools' // Function to call.
2265
+ );
2266
  if ( ! function_exists( 'is_plugin_active' ) ) {
2267
  // Need to include the plugin library for the is_plugin_active function.
2268
  require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
2269
  }
2270
  if ( ! is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
2271
  // Add options page to the settings menu.
2272
+ add_options_page(
2273
  'EWWW Image Optimizer', // Page title.
2274
  'EWWW Image Optimizer', // Menu title.
2275
  apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability.
2278
  );
2279
  } else {
2280
  // Add options page to the single-site settings menu.
2281
+ add_options_page(
2282
  'EWWW Image Optimizer', // Page title.
2283
  'EWWW Image Optimizer', // Menu title.
2284
  apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability.
2731
  return $paths_saved;
2732
  }
2733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2734
  /**
2735
  * Retrieves/sanitizes jpg background fill setting or returns null for png2jpg conversions.
2736
  *
3013
  ewwwio_ob_clean();
3014
  wp_die( ewwwio_json_encode( array( 'error' => esc_html__( 'No image ID was provided.', 'ewww-image-optimizer' ) ) ) );
3015
  }
3016
+ if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-tools' ) ) {
3017
  ewwwio_ob_clean();
3018
  wp_die( ewwwio_json_encode( array( 'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) ) ) );
3019
  }
6019
  } // End foreach().
6020
  } // End if().
6021
 
6022
+ // Original image detected.
6023
+ if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
6024
+ ewwwio_debug_message( 'processing original_image' );
6025
+ // Meta sizes don't contain a path, so we calculate one.
6026
+ $resize_path = trailingslashit( dirname( $file_path ) ) . $meta['original_image'];
6027
+ if ( $parallel_opt && is_file( $resize_path ) ) {
6028
+ $parallel_sizes['original_image'] = $resize_path;
6029
+ } else {
6030
+ $ewww_image = new EWWW_Image( $id, 'media', $resize_path );
6031
+ $ewww_image->resize = 'original_image';
6032
+ // Run the optimization and store the results.
6033
+ list( $optimized_file, $results, $resize_conv, $original ) = ewww_image_optimizer( $resize_path );
6034
+ }
6035
+ } // End if().
6036
+
6037
  // Process size from a custom theme.
6038
  if ( isset( $meta['image_meta']['resized_images'] ) && ewww_image_optimizer_iterable( $meta['image_meta']['resized_images'] ) ) {
6039
  $imagemeta_resize_pathinfo = pathinfo( $file_path );
7042
  // Give the user the option to optimize the image right now.
7043
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
7044
  $sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
7045
+ if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
7046
+ $sizes_to_opt++;
7047
+ }
7048
+ $output .= '<div>' . sprintf(
7049
  esc_html(
7050
  /* translators: %d: The number of resize/thumbnail images */
7051
  _n( '%d size to compress', '%d sizes to compress', $sizes_to_opt, 'ewww-image-optimizer' )
7133
  // Otherwise, this must be an image we haven't processed.
7134
  if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
7135
  $sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
7136
+ if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
7137
+ $sizes_to_opt++;
7138
+ }
7139
+ $output .= '<div>' . sprintf(
7140
  esc_html(
7141
  /* translators: %d: The number of resize/thumbnail images */
7142
  _n( '%d size to compress', '%d sizes to compress', $sizes_to_opt, 'ewww-image-optimizer' )
8105
  esc_html__( 'New images uploaded to the Media Library will be optimized automatically. If you have existing images you would like to optimize, you can use the %s tool.', 'ewww-image-optimizer' ),
8106
  $bulk_link
8107
  ) . ewwwio_help_link( 'https://docs.ewww.io/article/4-getting-started', '5853713bc697912ffd6c0b98' ) . ' ' .
8108
+ ( ! class_exists( 'Amazon_S3_And_CloudFront' ) ?
8109
  sprintf(
8110
  /* translators: %s: S3 Image Optimizer (link) */
8111
  esc_html__( 'Images stored in an Amazon S3 bucket can be optimized using our %s.' ),
8112
  $s3_link
8113
+ ) : '' ) .
8114
  "</p>\n";
8115
 
8116
  $compress_score = 0;
8417
  '</div><!-- end .ewww-guage -->';
8418
  $status_output .= $savings_guage;
8419
  $status_output .= '<p style="text-align:center"><strong>' . esc_html__( 'Savings', 'ewww-image-optimizer' ) . '</strong></p>';
8420
+ if ( 'network-multisite' !== $network ) {
8421
+ $status_output .= '<p><a href="tools.php?page=ewww-image-optimizer-tools">' . esc_html__( 'View optimized images.', 'ewww-image-optimizer' ) . '</a></p>';
8422
+ }
8423
  $status_output .= '</div><!-- end .ewww-status-detail --></li>';
8424
  }
8425
  ewwwio_debug_message( ewww_image_optimizer_aux_images_table_count() . ' images have been optimized' );
8668
  $output[] = "<tr class='$network_class'><th>&nbsp;</th><td>" .
8669
  '<p><span style="color: #3eadc9">' . esc_html__( '*Include Media Library Folders has been disabled because it will cause the scanner to ignore the disabled resizes.', 'ewww-image-optimizer' ) . "</span></p></td></tr>\n";
8670
  }
8671
+ $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_include_media_paths'>" .
8672
+ esc_html__( 'Include Media Folders', 'ewww-image-optimizer' ) . '</label>' .
8673
+ ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,5853713bc697912ffd6c0b98' ) .
8674
+ "</th><td><input type='checkbox' id='ewww_image_optimizer_include_media_paths' name='ewww_image_optimizer_include_media_paths' $media_include_disable value='true' " .
8675
+ ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) && ! get_option( 'ewww_image_optimizer_disable_resizes_opt' ) ? "checked='true'" : '' ) . ' /> ' .
8676
+ esc_html__( 'Scan all images from the latest two folders of the Media Library during the Bulk Optimizer and Scheduled Optimization.', 'ewww-image-optimizer' ) . "</td></tr>\n";
8677
  ewwwio_debug_message( 'include media library: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) ? 'on' : 'off' ) );
8678
+ $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_include_originals'>" .
8679
+ esc_html__( 'Include Originals', 'ewww-image-optimizer' ) . '</label>' .
8680
+ ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0' ) .
8681
+ "</th><td><input type='checkbox' id='ewww_image_optimizer_include_originals' name='ewww_image_optimizer_include_originals' value='true' " .
8682
+ ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ? "checked='true'" : '' ) . ' /> ' .
8683
+ esc_html__( 'Optimize the original version of images that have been scaled down by WordPress.', 'ewww-image-optimizer' ) . "</td></tr>\n";
8684
+ ewwwio_debug_message( 'include originals: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ? 'on' : 'off' ) );
8685
  $aux_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_aux_paths' ) ) ) : '';
8686
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_aux_paths'>" . esc_html__( 'Folders to Optimize', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,5853713bc697912ffd6c0b98' ) . '</th><td>' .
8687
  /* translators: %s: the folder where WordPress is installed */
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: 4.9.3
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
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.0.0
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
includes/eio-tools.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ var ewww_table_action = 'bulk_aux_images_table';
3
+ var ewww_table_count_action = 'bulk_aux_images_table_count';
4
+ $('#ewww-show-table').submit(function() {
5
+ var ewww_pointer = 0;
6
+ var ewww_total_pages = Math.ceil(ewww_vars.image_count / 50);
7
+ $('#ewww-table-info').hide();
8
+ $('#ewww-show-table').hide();
9
+ $('.ewww-aux-table').show();
10
+ if (ewww_vars.image_count >= 50) {
11
+ $('.tablenav').show();
12
+ $('#next-images').show();
13
+ $('.last-page').show();
14
+ }
15
+ var ewww_table_data = {
16
+ action: ewww_table_action,
17
+ ewww_wpnonce: ewww_vars._wpnonce,
18
+ ewww_offset: ewww_pointer,
19
+ };
20
+ $('.displaying-num').text(ewww_vars.count_string);
21
+ $.post(ajaxurl, ewww_table_data, function(response) {
22
+ $('#ewww-bulk-table').html(response);
23
+ });
24
+ $('.current-page').text(ewww_pointer + 1);
25
+ $('.total-pages').text(ewww_total_pages);
26
+ $('#ewww-pointer').text(ewww_pointer);
27
+ return false;
28
+ });
29
+ $('#next-images').click(function() {
30
+ var ewww_pointer = $('#ewww-pointer').text();
31
+ ewww_pointer++;
32
+ var ewww_table_data = {
33
+ action: ewww_table_action,
34
+ ewww_wpnonce: ewww_vars._wpnonce,
35
+ ewww_offset: ewww_pointer,
36
+ };
37
+ $.post(ajaxurl, ewww_table_data, function(response) {
38
+ $('#ewww-bulk-table').html(response);
39
+ });
40
+ if (ewww_vars.image_count <= ((ewww_pointer + 1) * 50)) {
41
+ $('#next-images').hide();
42
+ $('.last-page').hide();
43
+ }
44
+ $('.current-page').text(ewww_pointer + 1);
45
+ $('#ewww-pointer').text(ewww_pointer);
46
+ $('#prev-images').show();
47
+ $('.first-page').show();
48
+ return false;
49
+ });
50
+ $('#prev-images').click(function() {
51
+ var ewww_pointer = $('#ewww-pointer').text();
52
+ ewww_pointer--;
53
+ var ewww_table_data = {
54
+ action: ewww_table_action,
55
+ ewww_wpnonce: ewww_vars._wpnonce,
56
+ ewww_offset: ewww_pointer,
57
+ };
58
+ $.post(ajaxurl, ewww_table_data, function(response) {
59
+ $('#ewww-bulk-table').html(response);
60
+ });
61
+ if (!ewww_pointer) {
62
+ $('#prev-images').hide();
63
+ $('.first-page').hide();
64
+ }
65
+ $('.current-page').text(ewww_pointer + 1);
66
+ $('#ewww-pointer').text(ewww_pointer);
67
+ $('#next-images').show();
68
+ $('.last-page').show();
69
+ return false;
70
+ });
71
+ $('.last-page').click(function() {
72
+ var ewww_pointer = $('.total-pages').text();
73
+ ewww_pointer--;
74
+ var ewww_table_data = {
75
+ action: ewww_table_action,
76
+ ewww_wpnonce: ewww_vars._wpnonce,
77
+ ewww_offset: ewww_pointer,
78
+ };
79
+ $.post(ajaxurl, ewww_table_data, function(response) {
80
+ $('#ewww-bulk-table').html(response);
81
+ });
82
+ $('#next-images').hide();
83
+ $('.last-page').hide();
84
+ $('.current-page').text(ewww_pointer + 1);
85
+ $('#ewww-pointer').text(ewww_pointer);
86
+ $('#prev-images').show();
87
+ $('.first-page').show();
88
+ return false;
89
+ });
90
+ $('.first-page').click(function() {
91
+ var ewww_pointer = 0;
92
+ var ewww_table_data = {
93
+ action: ewww_table_action,
94
+ ewww_wpnonce: ewww_vars._wpnonce,
95
+ ewww_offset: ewww_pointer,
96
+ };
97
+ $.post(ajaxurl, ewww_table_data, function(response) {
98
+ $('#ewww-bulk-table').html(response);
99
+ });
100
+ $('#prev-images').hide();
101
+ $('.first-page').hide();
102
+ $('.current-page').text(ewww_pointer + 1);
103
+ $('#ewww-pointer').text(ewww_pointer);
104
+ $('#next-images').show();
105
+ $('.last-page').show();
106
+ return false;
107
+ });
108
+ $('#ewww-clear-table').submit(function() {
109
+ var ewww_table_data = {
110
+ action: 'bulk_aux_images_table_clear',
111
+ ewww_wpnonce: ewww_vars._wpnonce,
112
+ };
113
+ if (confirm(ewww_vars.erase_warning)) {
114
+ $.post(ajaxurl, ewww_table_data, function(response) {
115
+ $('#ewww-table-info').hide();
116
+ $('#ewww-show-table').hide();
117
+ $('#ewww-clear-table').hide();
118
+ $('#ewww-clear-table-info').html(response);
119
+ });
120
+ }
121
+ return false;
122
+ });
123
+ });
124
+ function ewwwRemoveImage(imageID) {
125
+ var ewww_image_removal = {
126
+ action: 'bulk_aux_images_remove',
127
+ ewww_wpnonce: ewww_vars._wpnonce,
128
+ ewww_image_id: imageID,
129
+ };
130
+ jQuery.post(ajaxurl, ewww_image_removal, function(response) {
131
+ if(response == '1') {
132
+ jQuery('#ewww-image-' + imageID).remove();
133
+ var ewww_prev_count = ewww_vars.image_count;
134
+ ewww_vars.image_count--;
135
+ ewww_vars.count_string = ewww_vars.count_string.replace( ewww_prev_count, ewww_vars.image_count );
136
+ jQuery('.displaying-num').text(ewww_vars.count_string);
137
+ } else {
138
+ alert(ewww_vars.remove_failed);
139
+ }
140
+ });
141
+ }
142
+ function ewwwRestoreImage(imageID) {
143
+ var ewww_image_restore = {
144
+ action: 'ewww_manual_cloud_restore_single',
145
+ ewww_wpnonce: ewww_vars._wpnonce,
146
+ ewww_image_id: imageID,
147
+ };
148
+ var original_html = jQuery('#ewww-image-' + imageID + ' td:last-child').html();
149
+ jQuery('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.restoring);
150
+ jQuery.post(ajaxurl, ewww_image_restore, function(response) {
151
+ var is_json = true;
152
+ try {
153
+ var ewww_response = jQuery.parseJSON(response);
154
+ } catch (err) {
155
+ is_json = false;
156
+ }
157
+ if ( ! is_json ) {
158
+ alert( ewww_vars.invalid_response );
159
+ console.log( response );
160
+ return false;
161
+ }
162
+ if ( ewww_response.success == '1') {
163
+ jQuery('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.original_restored);
164
+ return false;
165
+ } else if (ewww_response.error) {
166
+ jQuery('#ewww-image-' + imageID + ' td:last-child').html(original_html);
167
+ alert(ewww_response.error);
168
+ return false;
169
+ }
170
+ });
171
+ }
includes/eio.js CHANGED
@@ -234,284 +234,180 @@ jQuery(document).ready(function($) {
234
  });
235
  return false;
236
  } else {
237
- $(function() {
238
- $("#ewww-delay-slider").slider({
239
- min: 0,
240
- max: 30,
241
- value: $("#ewww-delay").val(),
242
- slide: function(event, ui) {
243
- $("#ewww-delay").val(ui.value);
244
- }
 
245
  });
246
- });
247
- var ewwwdelayinput = document.getElementById("ewww-delay");
248
- ewwwdelayinput.onblur = function() {
249
- if (isNaN(this.value)) {
250
- this.value = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  } else {
252
- this.value = Math.ceil(this.value);
253
- }
254
- };
255
- var ewww_attachments = ewww_vars.attachments;
256
- var ewww_i = 0;
257
- var ewww_k = 0;
258
- var ewww_import_total = 0;
259
- var ewww_force = 0;
260
- var ewww_delay = 0;
261
- var ewww_batch_limit = 0;
262
- var ewww_aux = false;
263
- var ewww_main = false;
264
- var ewww_quota_update = 0;
265
- var ewww_scan_failures = 0;
266
- var ewww_bulk_start_time = 0;
267
- var ewww_bulk_elapsed_time = 0;
268
- var ewww_time_per_image = 0;
269
- var ewww_time_remaining = 0;
270
- var ewww_days_remaining = 0;
271
- var ewww_hours_remaining = 0;
272
- var ewww_minutes_remaining = 0;
273
- var ewww_seconds_remaining = 0;
274
- var ewww_countdown = false;
275
- var ewww_tiny_skip = '';
276
- // initialize the ajax actions for the appropriate bulk page
277
- var ewww_quota_update_data = {
278
- action: 'bulk_quota_update',
279
- ewww_wpnonce: ewww_vars._wpnonce,
280
- };
281
- if (ewww_vars.gallery == 'flag') {
282
- var ewww_init_action = 'bulk_flag_init';
283
- var ewww_loop_action = 'bulk_flag_loop';
284
- var ewww_cleanup_action = 'bulk_flag_cleanup';
285
- } else if (ewww_vars.gallery == 'nextgen') {
286
- var ewww_preview_action = 'bulk_ngg_preview';
287
- var ewww_init_action = 'bulk_ngg_init';
288
- var ewww_loop_action = 'bulk_ngg_loop';
289
- var ewww_cleanup_action = 'bulk_ngg_cleanup';
290
- } else {
291
- var ewww_scan_action = 'bulk_scan';
292
- var ewww_init_action = 'bulk_init';
293
- var ewww_loop_action = 'bulk_loop';
294
- var ewww_cleanup_action = 'bulk_cleanup';
295
- ewww_main = true;
296
- }
297
- var ewww_init_data = {
298
- action: ewww_init_action,
299
- ewww_wpnonce: ewww_vars._wpnonce,
300
- };
301
- var ewww_table_action = 'bulk_aux_images_table';
302
- var ewww_table_count_action = 'bulk_aux_images_table_count';
303
- var ewww_import_init_action = 'bulk_import_init';
304
- var ewww_import_loop_action = 'bulk_import_loop';
305
- $(document).on('click', '.ewww-show-debug-meta', function() {
306
- var post_id = $(this).data('id');
307
- $('.ewww-debug-meta-' + post_id).toggle();
308
- });
309
- $('#ewww-aux-start').submit(function() {
310
- ewww_aux = true;
311
- //ewww_init_action = 'bulk_init';
312
- //ewww_loop_action = 'bulk_aux_images_loop';
313
- //ewww_cleanup_action = 'bulk_aux_images_cleanup';
314
- if ($('#ewww-force:checkbox:checked').val()) {
315
- ewww_force = 1;
316
  }
317
- $('#ewww-aux-start').hide();
318
- $('.ewww-bulk-info').hide();
319
- $('.ewww-aux-table').hide();
320
- $('#ewww-show-table').hide();
321
- $('#ewww-scanning').show();
322
- //ewww_vars.scanning = $('#ewww-scanning').html();
323
- ewwwStartScan();
324
- return false;
325
- });
326
- function ewwwStartScan() {
327
- var ewww_scan_data = {
328
- action: ewww_scan_action,
329
- ewww_force: ewww_force,
330
- ewww_scan: true,
331
  ewww_wpnonce: ewww_vars._wpnonce,
332
  };
333
- $.post(ajaxurl, ewww_scan_data, function(response) {
334
- var is_json = true;
335
- try {
336
- var ewww_response = $.parseJSON(response);
337
- } catch (err) {
338
- is_json = false;
339
- }
340
- if ( ! is_json ) {
341
- $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
342
- console.log( response );
343
- return false;
 
 
 
 
344
  }
345
- ewww_init_data = {
346
- action: ewww_init_action,
 
 
 
 
 
 
 
 
 
 
 
 
347
  ewww_wpnonce: ewww_vars._wpnonce,
348
  };
349
- if ( ewww_response.error ) {
350
- $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_response.error + '</b></span>');
351
- } else if ( ewww_response.remaining ) {
352
- $('.ewww-aux-table').hide();
353
- $('#ewww-show-table').hide();
354
- //if ( ! ewww_response.notice ) {
355
- // ewww_response.notice = '';
356
- //}
357
- $('#ewww-scanning').html( ewww_response.remaining );
358
- if ( ewww_response.notice ) {
359
- $('#ewww-scanning').append( '<br>' + ewww_response.notice );
360
  }
361
- if ( ewww_response.tiny_skip ) {
362
- $('#ewww-scanning').append( '<br>' + ewww_response.tiny_skip );
363
- ewww_tiny_skip = ewww_response.tiny_skip;
364
- console.log( 'skipped some tiny images' );
365
- }
366
- if ( ewww_response.bad_attachment ) {
367
- $('#ewww-scanning').append( '<br>' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment );
368
  }
369
- ewww_scan_failures = 0;
370
- ewwwStartScan();
371
- } else if ( ewww_response.ready ) {
372
- ewww_attachments = ewww_response.ready;
373
- if (ewww_attachments == 0) {
374
- // $('#ewww-bulk-loading').hide();
375
- $('#ewww-scanning').hide();
376
- $('#ewww-nothing').show();
377
- if ( ewww_tiny_skip ) {
378
- $('#ewww-nothing').append( '<br><i>' + ewww_tiny_skip + '</i>' );
379
- console.log( 'done, skipped some tiny images' );
 
 
 
 
380
  }
381
- //$('#ewww-aux-start').show();
382
- //$('#ewww-aux-again').show();
383
- //$('#ewww-aux-first').hide();
384
- } else {
385
- $('#ewww-scanning').html(ewww_response.message);
386
- if ( ewww_tiny_skip ) {
387
- $('#ewww-scanning').append( '<br><i>' + ewww_tiny_skip + '</i>' );
388
- console.log( 'done, skipped some tiny images' );
389
  }
390
- $('#ewww-bulk-start').show();
391
- // ewwwStartOpt();
392
- }
393
- }
394
- })
395
- .fail(function() {
396
- ewww_scan_failures++;
397
- if (ewww_scan_failures > 10) {
398
- $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_fail + ':</b> ' + ewww_vars.bulk_fail_more + '</span>');
399
- } else {
400
- $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_incomplete + '</b></span>');
401
- setTimeout(function() {
402
  ewwwStartScan();
403
- }, 1000);
404
- }
405
- });
406
- }
407
- $('#ewww-show-table').submit(function() {
408
- var ewww_pointer = 0;
409
- var ewww_total_pages = Math.ceil(ewww_vars.image_count / 50);
410
- $('.ewww-aux-table').show();
411
- $('#ewww-show-table').hide();
412
- $('#ewww-table-info').hide();
413
- if (ewww_vars.image_count >= 50) {
414
- $('.tablenav').show();
415
- $('#next-images').show();
416
- $('.last-page').show();
417
- }
418
- var ewww_table_data = {
419
- action: ewww_table_action,
420
- ewww_wpnonce: ewww_vars._wpnonce,
421
- ewww_offset: ewww_pointer,
422
- };
423
- $('.displaying-num').text(ewww_vars.count_string);
424
- $.post(ajaxurl, ewww_table_data, function(response) {
425
- $('#ewww-bulk-table').html(response);
426
- });
427
- $('.current-page').text(ewww_pointer + 1);
428
- $('.total-pages').text(ewww_total_pages);
429
- $('#ewww-pointer').text(ewww_pointer);
430
- return false;
431
- });
432
- $('#next-images').click(function() {
433
- var ewww_pointer = $('#ewww-pointer').text();
434
- ewww_pointer++;
435
- var ewww_table_data = {
436
- action: ewww_table_action,
437
- ewww_wpnonce: ewww_vars._wpnonce,
438
- ewww_offset: ewww_pointer,
439
- };
440
- $.post(ajaxurl, ewww_table_data, function(response) {
441
- $('#ewww-bulk-table').html(response);
442
- });
443
- if (ewww_vars.image_count <= ((ewww_pointer + 1) * 50)) {
444
- $('#next-images').hide();
445
- $('.last-page').hide();
446
- }
447
- $('.current-page').text(ewww_pointer + 1);
448
- $('#ewww-pointer').text(ewww_pointer);
449
- $('#prev-images').show();
450
- $('.first-page').show();
451
- return false;
452
- });
453
- $('#prev-images').click(function() {
454
- var ewww_pointer = $('#ewww-pointer').text();
455
- ewww_pointer--;
456
- var ewww_table_data = {
457
- action: ewww_table_action,
458
- ewww_wpnonce: ewww_vars._wpnonce,
459
- ewww_offset: ewww_pointer,
460
- };
461
- $.post(ajaxurl, ewww_table_data, function(response) {
462
- $('#ewww-bulk-table').html(response);
463
- });
464
- if (!ewww_pointer) {
465
- $('#prev-images').hide();
466
- $('.first-page').hide();
467
  }
468
- $('.current-page').text(ewww_pointer + 1);
469
- $('#ewww-pointer').text(ewww_pointer);
470
- $('#next-images').show();
471
- $('.last-page').show();
472
- return false;
473
- });
474
- $('.last-page').click(function() {
475
- var ewww_pointer = $('.total-pages').text();
476
- ewww_pointer--;
477
- var ewww_table_data = {
478
- action: ewww_table_action,
479
- ewww_wpnonce: ewww_vars._wpnonce,
480
- ewww_offset: ewww_pointer,
481
- };
482
- $.post(ajaxurl, ewww_table_data, function(response) {
483
- $('#ewww-bulk-table').html(response);
484
- });
485
- $('#next-images').hide();
486
- $('.last-page').hide();
487
- $('.current-page').text(ewww_pointer + 1);
488
- $('#ewww-pointer').text(ewww_pointer);
489
- $('#prev-images').show();
490
- $('.first-page').show();
491
- return false;
492
- });
493
- $('.first-page').click(function() {
494
- var ewww_pointer = 0;
495
- var ewww_table_data = {
496
- action: ewww_table_action,
497
- ewww_wpnonce: ewww_vars._wpnonce,
498
- ewww_offset: ewww_pointer,
499
- };
500
- $.post(ajaxurl, ewww_table_data, function(response) {
501
- $('#ewww-bulk-table').html(response);
502
  });
503
- $('#prev-images').hide();
504
- $('.first-page').hide();
505
- $('.current-page').text(ewww_pointer + 1);
506
- $('#ewww-pointer').text(ewww_pointer);
507
- $('#next-images').show();
508
- $('.last-page').show();
509
- return false;
510
- });
511
- $('#ewww-bulk-start').submit(function() {
512
- ewwwStartOpt();
513
- return false;
514
- });
515
  }
516
  function ewwwUpdateQuota() {
517
  if ($('#ewww-bulk-credits-available').length > 0) {
234
  });
235
  return false;
236
  } else {
237
+ $(function() {
238
+ $("#ewww-delay-slider").slider({
239
+ min: 0,
240
+ max: 30,
241
+ value: $("#ewww-delay").val(),
242
+ slide: function(event, ui) {
243
+ $("#ewww-delay").val(ui.value);
244
+ }
245
+ });
246
  });
247
+ var ewwwdelayinput = document.getElementById("ewww-delay");
248
+ ewwwdelayinput.onblur = function() {
249
+ if (isNaN(this.value)) {
250
+ this.value = 0;
251
+ } else {
252
+ this.value = Math.ceil(this.value);
253
+ }
254
+ };
255
+ var ewww_attachments = ewww_vars.attachments;
256
+ var ewww_i = 0;
257
+ var ewww_k = 0;
258
+ var ewww_import_total = 0;
259
+ var ewww_force = 0;
260
+ var ewww_delay = 0;
261
+ var ewww_batch_limit = 0;
262
+ var ewww_aux = false;
263
+ var ewww_main = false;
264
+ var ewww_quota_update = 0;
265
+ var ewww_scan_failures = 0;
266
+ var ewww_bulk_start_time = 0;
267
+ var ewww_bulk_elapsed_time = 0;
268
+ var ewww_time_per_image = 0;
269
+ var ewww_time_remaining = 0;
270
+ var ewww_days_remaining = 0;
271
+ var ewww_hours_remaining = 0;
272
+ var ewww_minutes_remaining = 0;
273
+ var ewww_seconds_remaining = 0;
274
+ var ewww_countdown = false;
275
+ var ewww_tiny_skip = '';
276
+ // initialize the ajax actions for the appropriate bulk page
277
+ var ewww_quota_update_data = {
278
+ action: 'bulk_quota_update',
279
+ ewww_wpnonce: ewww_vars._wpnonce,
280
+ };
281
+ if (ewww_vars.gallery == 'flag') {
282
+ var ewww_init_action = 'bulk_flag_init';
283
+ var ewww_loop_action = 'bulk_flag_loop';
284
+ var ewww_cleanup_action = 'bulk_flag_cleanup';
285
+ } else if (ewww_vars.gallery == 'nextgen') {
286
+ var ewww_preview_action = 'bulk_ngg_preview';
287
+ var ewww_init_action = 'bulk_ngg_init';
288
+ var ewww_loop_action = 'bulk_ngg_loop';
289
+ var ewww_cleanup_action = 'bulk_ngg_cleanup';
290
  } else {
291
+ var ewww_scan_action = 'bulk_scan';
292
+ var ewww_init_action = 'bulk_init';
293
+ var ewww_loop_action = 'bulk_loop';
294
+ var ewww_cleanup_action = 'bulk_cleanup';
295
+ ewww_main = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
+ var ewww_init_data = {
298
+ action: ewww_init_action,
 
 
 
 
 
 
 
 
 
 
 
 
299
  ewww_wpnonce: ewww_vars._wpnonce,
300
  };
301
+ var ewww_table_action = 'bulk_aux_images_table';
302
+ var ewww_table_count_action = 'bulk_aux_images_table_count';
303
+ var ewww_import_init_action = 'bulk_import_init';
304
+ var ewww_import_loop_action = 'bulk_import_loop';
305
+ $(document).on('click', '.ewww-show-debug-meta', function() {
306
+ var post_id = $(this).data('id');
307
+ $('.ewww-debug-meta-' + post_id).toggle();
308
+ });
309
+ $('#ewww-aux-start').submit(function() {
310
+ ewww_aux = true;
311
+ //ewww_init_action = 'bulk_init';
312
+ //ewww_loop_action = 'bulk_aux_images_loop';
313
+ //ewww_cleanup_action = 'bulk_aux_images_cleanup';
314
+ if ($('#ewww-force:checkbox:checked').val()) {
315
+ ewww_force = 1;
316
  }
317
+ $('#ewww-aux-start').hide();
318
+ $('.ewww-bulk-info').hide();
319
+ $('.ewww-aux-table').hide();
320
+ $('#ewww-show-table').hide();
321
+ $('#ewww-scanning').show();
322
+ //ewww_vars.scanning = $('#ewww-scanning').html();
323
+ ewwwStartScan();
324
+ return false;
325
+ });
326
+ function ewwwStartScan() {
327
+ var ewww_scan_data = {
328
+ action: ewww_scan_action,
329
+ ewww_force: ewww_force,
330
+ ewww_scan: true,
331
  ewww_wpnonce: ewww_vars._wpnonce,
332
  };
333
+ $.post(ajaxurl, ewww_scan_data, function(response) {
334
+ var is_json = true;
335
+ try {
336
+ var ewww_response = $.parseJSON(response);
337
+ } catch (err) {
338
+ is_json = false;
 
 
 
 
 
339
  }
340
+ if ( ! is_json ) {
341
+ $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
342
+ console.log( response );
343
+ return false;
 
 
 
344
  }
345
+ ewww_init_data = {
346
+ action: ewww_init_action,
347
+ ewww_wpnonce: ewww_vars._wpnonce,
348
+ };
349
+ if ( ewww_response.error ) {
350
+ $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_response.error + '</b></span>');
351
+ } else if ( ewww_response.remaining ) {
352
+ $('.ewww-aux-table').hide();
353
+ $('#ewww-show-table').hide();
354
+ //if ( ! ewww_response.notice ) {
355
+ // ewww_response.notice = '';
356
+ //}
357
+ $('#ewww-scanning').html( ewww_response.remaining );
358
+ if ( ewww_response.notice ) {
359
+ $('#ewww-scanning').append( '<br>' + ewww_response.notice );
360
  }
361
+ if ( ewww_response.tiny_skip ) {
362
+ $('#ewww-scanning').append( '<br>' + ewww_response.tiny_skip );
363
+ ewww_tiny_skip = ewww_response.tiny_skip;
364
+ console.log( 'skipped some tiny images' );
 
 
 
 
365
  }
366
+ if ( ewww_response.bad_attachment ) {
367
+ $('#ewww-scanning').append( '<br>' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment );
368
+ }
369
+ ewww_scan_failures = 0;
 
 
 
 
 
 
 
 
370
  ewwwStartScan();
371
+ } else if ( ewww_response.ready ) {
372
+ ewww_attachments = ewww_response.ready;
373
+ if (ewww_attachments == 0) {
374
+ // $('#ewww-bulk-loading').hide();
375
+ $('#ewww-scanning').hide();
376
+ $('#ewww-nothing').show();
377
+ if ( ewww_tiny_skip ) {
378
+ $('#ewww-nothing').append( '<br><i>' + ewww_tiny_skip + '</i>' );
379
+ console.log( 'done, skipped some tiny images' );
380
+ }
381
+ //$('#ewww-aux-start').show();
382
+ //$('#ewww-aux-again').show();
383
+ //$('#ewww-aux-first').hide();
384
+ } else {
385
+ $('#ewww-scanning').html(ewww_response.message);
386
+ if ( ewww_tiny_skip ) {
387
+ $('#ewww-scanning').append( '<br><i>' + ewww_tiny_skip + '</i>' );
388
+ console.log( 'done, skipped some tiny images' );
389
+ }
390
+ $('#ewww-bulk-start').show();
391
+ // ewwwStartOpt();
392
+ }
393
+ }
394
+ })
395
+ .fail(function() {
396
+ ewww_scan_failures++;
397
+ if (ewww_scan_failures > 10) {
398
+ $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_fail + ':</b> ' + ewww_vars.bulk_fail_more + '</span>');
399
+ } else {
400
+ $('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_incomplete + '</b></span>');
401
+ setTimeout(function() {
402
+ ewwwStartScan();
403
+ }, 1000);
404
+ }
405
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  }
407
+ $('#ewww-bulk-start').submit(function() {
408
+ ewwwStartOpt();
409
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  });
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
412
  function ewwwUpdateQuota() {
413
  if ($('#ewww-bulk-credits-available').length > 0) {
includes/lazysizes.js CHANGED
@@ -4,12 +4,55 @@
4
  if(typeof module == 'object' && module.exports){
5
  module.exports = lazySizes;
6
  }
7
- }(window, function l(window, document) {
 
8
  'use strict';
9
  /*jshint eqnull:true */
10
- if(!document.getElementsByClassName){return;}
11
 
12
- var lazysizes, lazySizesConfig;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  var docElem = document.documentElement;
15
 
@@ -86,7 +129,7 @@
86
 
87
  var updatePolyfill = function (el, full){
88
  var polyfill;
89
- if( !supportPicture && ( polyfill = (window.picturefill || lazySizesConfig.pf) ) ){
90
  if(full && full.src && !el[_getAttribute]('srcset')){
91
  el.setAttribute('srcset', full.src);
92
  }
@@ -103,7 +146,7 @@
103
  var getWidth = function(elem, parent, width){
104
  width = width || elem.offsetWidth;
105
 
106
- while(width < lazySizesConfig.minSize && parent && !elem._lazysizesWidth){
107
  width = parent.offsetWidth;
108
  parent = parent.parentNode;
109
  }
@@ -168,8 +211,8 @@
168
  var throttle = function(fn){
169
  var running;
170
  var lastTime = 0;
171
- var gDelay = lazySizesConfig.throttleDelay;
172
- var rICTimeout = lazySizesConfig.ricTimeout;
173
  var run = function(){
174
  running = false;
175
  lastTime = Date.now();
@@ -179,8 +222,8 @@
179
  function(){
180
  requestIdleCallback(run, {timeout: rICTimeout});
181
 
182
- if(rICTimeout !== lazySizesConfig.ricTimeout){
183
- rICTimeout = lazySizesConfig.ricTimeout;
184
  }
185
  } :
186
  rAFIt(function(){
@@ -242,49 +285,6 @@
242
  };
243
  };
244
 
245
- (function(){
246
- var prop;
247
-
248
- var lazySizesDefaults = {
249
- lazyClass: 'lazyload',
250
- loadedClass: 'lazyloaded',
251
- loadingClass: 'lazyloading',
252
- preloadClass: 'lazypreload',
253
- errorClass: 'lazyerror',
254
- //strictClass: 'lazystrict',
255
- autosizesClass: 'lazyautosizes',
256
- srcAttr: 'data-src',
257
- srcsetAttr: 'data-srcset',
258
- sizesAttr: 'data-sizes',
259
- //preloadAfterLoad: false,
260
- minSize: 40,
261
- customMedia: {},
262
- init: true,
263
- expFactor: 1.5,
264
- hFac: 0.8,
265
- loadMode: 2,
266
- loadHidden: true,
267
- ricTimeout: 0,
268
- throttleDelay: 125,
269
- };
270
-
271
- lazySizesConfig = window.lazySizesConfig || window.lazysizesConfig || {};
272
-
273
- for(prop in lazySizesDefaults){
274
- if(!(prop in lazySizesConfig)){
275
- lazySizesConfig[prop] = lazySizesDefaults[prop];
276
- }
277
- }
278
-
279
- window.lazySizesConfig = lazySizesConfig;
280
-
281
- setTimeout(function(){
282
- if(lazySizesConfig.init){
283
- init();
284
- }
285
- });
286
- })();
287
-
288
  var loader = (function(){
289
  var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;
290
 
@@ -347,41 +347,43 @@
347
  beforeExpandVal, defaultExpand, preloadExpand, hFac;
348
  var lazyloadElems = lazysizes.elements;
349
 
350
- if((loadMode = lazySizesConfig.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
351
 
352
  i = 0;
353
 
354
  lowRuns++;
355
 
356
- defaultExpand = (!lazySizesConfig.expand || lazySizesConfig.expand < 1) ?
357
- docElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370 :
358
- lazySizesConfig.expand;
359
-
360
- lazysizes._defEx = defaultExpand;
361
-
362
- preloadExpand = defaultExpand * lazySizesConfig.expFactor;
363
- hFac = lazySizesConfig.hFac;
364
- isBodyHidden = null;
365
-
366
- if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden){
367
- currentExpand = preloadExpand;
368
- lowRuns = 0;
369
- } else if(loadMode > 1 && lowRuns > 1 && isLoading < 6){
370
- currentExpand = defaultExpand;
371
- } else {
372
- currentExpand = shrinkExpand;
373
- }
374
-
375
  for(; i < eLlen; i++){
376
 
377
  if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
378
 
379
- if(!supportScroll){unveilElement(lazyloadElems[i]);continue;}
380
 
381
  if(!(elemExpandVal = lazyloadElems[i][_getAttribute]('data-expand')) || !(elemExpand = elemExpandVal * 1)){
382
  elemExpand = currentExpand;
383
  }
384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  if(beforeExpandVal !== elemExpand){
386
  eLvW = innerWidth + (elemExpand * hFac);
387
  elvH = innerHeight + elemExpand;
@@ -396,15 +398,15 @@
396
  (eLright = rect.right) >= elemNegativeExpand * hFac &&
397
  (eLleft = rect.left) <= eLvW &&
398
  (eLbottom || eLright || eLleft || eLtop) &&
399
- (lazySizesConfig.loadHidden || isVisible(lazyloadElems[i])) &&
400
  ((isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4)) || isNestedVisible(lazyloadElems[i], elemExpand))){
401
  unveilElement(lazyloadElems[i]);
402
  loadedSomething = true;
403
  if(isLoading > 9){break;}
404
  } else if(!loadedSomething && isCompleted && !autoLoadElem &&
405
  isLoading < 4 && lowRuns < 4 && loadMode > 2 &&
406
- (preloadElems[0] || lazySizesConfig.preloadAfterLoad) &&
407
- (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesConfig.sizesAttr) != 'auto')))){
408
  autoLoadElem = preloadElems[0] || lazyloadElems[i];
409
  }
410
  }
@@ -426,8 +428,8 @@
426
  }
427
 
428
  resetPreloading(e);
429
- addClass(elem, lazySizesConfig.loadedClass);
430
- removeClass(elem, lazySizesConfig.loadingClass);
431
  addRemoveLoadEvents(elem, rafSwitchLoadingClass);
432
  triggerEvent(elem, 'lazyloaded');
433
  };
@@ -447,9 +449,9 @@
447
  var handleSources = function(source){
448
  var customMedia;
449
 
450
- var sourceSrcset = source[_getAttribute](lazySizesConfig.srcsetAttr);
451
 
452
- if( (customMedia = lazySizesConfig.customMedia[source[_getAttribute]('data-media') || source[_getAttribute]('media')]) ){
453
  source.setAttribute('media', customMedia);
454
  }
455
 
@@ -465,14 +467,14 @@
465
 
466
  if(sizes){
467
  if(isAuto){
468
- addClass(elem, lazySizesConfig.autosizesClass);
469
  } else {
470
  elem.setAttribute('sizes', sizes);
471
  }
472
  }
473
 
474
- srcset = elem[_getAttribute](lazySizesConfig.srcsetAttr);
475
- src = elem[_getAttribute](lazySizesConfig.srcAttr);
476
 
477
  if(isImg) {
478
  parent = elem.parentNode;
@@ -483,7 +485,7 @@
483
 
484
  event = {target: elem};
485
 
486
- addClass(elem, lazySizesConfig.loadingClass);
487
 
488
  if(firesLoad){
489
  clearTimeout(resetPreloadingTimer);
@@ -513,11 +515,16 @@
513
  if(elem._lazyRace){
514
  delete elem._lazyRace;
515
  }
516
- removeClass(elem, lazySizesConfig.lazyClass);
517
 
518
  rAF(function(){
519
  // Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015)
520
- if( !firesLoad || (elem.complete && elem.naturalWidth > 1)){
 
 
 
 
 
521
  switchLoadingClass(event);
522
  elem._lazyCache = true;
523
  setTimeout(function(){
@@ -526,19 +533,23 @@
526
  }
527
  }, 9);
528
  }
 
 
 
529
  }, true);
530
  });
531
 
532
  var unveilElement = function (elem){
 
533
  var detail;
534
 
535
  var isImg = regImg.test(elem.nodeName);
536
 
537
  //allow using sizes="auto", but don't use. it's invalid. Use data-sizes="auto" or a valid value for sizes instead (i.e.: sizes="80vw")
538
- var sizes = isImg && (elem[_getAttribute](lazySizesConfig.sizesAttr) || elem[_getAttribute]('sizes'));
539
  var isAuto = sizes == 'auto';
540
 
541
- if( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesConfig.errorClass) && hasClass(elem, lazySizesConfig.lazyClass)){return;}
542
 
543
  detail = triggerEvent(elem, 'lazyunveilread').detail;
544
 
@@ -552,37 +563,41 @@
552
  lazyUnveil(elem, detail, isAuto, sizes, isImg);
553
  };
554
 
 
 
 
 
 
 
 
 
 
 
 
 
555
  var onload = function(){
556
  if(isCompleted){return;}
557
  if(Date.now() - started < 999){
558
  setTimeout(onload, 999);
559
  return;
560
  }
561
- var afterScroll = debounce(function(){
562
- lazySizesConfig.loadMode = 3;
563
- throttledCheckElements();
564
- });
565
 
566
  isCompleted = true;
567
 
568
- lazySizesConfig.loadMode = 3;
569
 
570
  throttledCheckElements();
571
 
572
- addEventListener('scroll', function(){
573
- if(lazySizesConfig.loadMode == 3){
574
- lazySizesConfig.loadMode = 2;
575
- }
576
- afterScroll();
577
- }, true);
578
  };
579
 
580
  return {
581
  _: function(){
582
  started = Date.now();
583
 
584
- lazysizes.elements = document.getElementsByClassName(lazySizesConfig.lazyClass);
585
- preloadElems = document.getElementsByClassName(lazySizesConfig.lazyClass + ' ' + lazySizesConfig.preloadClass);
586
 
587
  addEventListener('scroll', throttledCheckElements, true);
588
 
@@ -599,7 +614,7 @@
599
  addEventListener('hashchange', throttledCheckElements, true);
600
 
601
  //, 'fullscreenchange'
602
- ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend', 'webkitAnimationEnd'].forEach(function(name){
603
  document[_addEventListener](name, throttledCheckElements, true);
604
  });
605
 
@@ -619,7 +634,8 @@
619
  }
620
  },
621
  checkElems: throttledCheckElements,
622
- unveil: unveilElement
 
623
  };
624
  })();
625
 
@@ -679,7 +695,7 @@
679
 
680
  return {
681
  _: function(){
682
- autosizesElems = document.getElementsByClassName(lazySizesConfig.autosizesClass);
683
  addEventListener('resize', debouncedUpdateElementsSizes);
684
  },
685
  checkElems: debouncedUpdateElementsSizes,
@@ -688,15 +704,21 @@
688
  })();
689
 
690
  var init = function(){
691
- if(!init.i){
692
  init.i = true;
693
  autoSizer._();
694
  loader._();
695
  }
696
  };
697
 
 
 
 
 
 
 
698
  lazysizes = {
699
- cfg: lazySizesConfig,
700
  autoSizer: autoSizer,
701
  loader: loader,
702
  init: init,
4
  if(typeof module == 'object' && module.exports){
5
  module.exports = lazySizes;
6
  }
7
+ }(typeof window != 'undefined' ?
8
+ window : {}, function l(window, document) {
9
  'use strict';
10
  /*jshint eqnull:true */
 
11
 
12
+ var lazysizes, lazySizesCfg;
13
+
14
+ (function(){
15
+ var prop;
16
+
17
+ var lazySizesDefaults = {
18
+ lazyClass: 'lazyload',
19
+ loadedClass: 'lazyloaded',
20
+ loadingClass: 'lazyloading',
21
+ preloadClass: 'lazypreload',
22
+ errorClass: 'lazyerror',
23
+ //strictClass: 'lazystrict',
24
+ autosizesClass: 'lazyautosizes',
25
+ srcAttr: 'data-src',
26
+ srcsetAttr: 'data-srcset',
27
+ sizesAttr: 'data-sizes',
28
+ //preloadAfterLoad: false,
29
+ minSize: 40,
30
+ customMedia: {},
31
+ init: true,
32
+ expFactor: 1.5,
33
+ hFac: 0.8,
34
+ loadMode: 2,
35
+ loadHidden: true,
36
+ ricTimeout: 0,
37
+ throttleDelay: 125,
38
+ };
39
+
40
+ lazySizesCfg = window.lazySizesConfig || window.lazysizesConfig || {};
41
+
42
+ for(prop in lazySizesDefaults){
43
+ if(!(prop in lazySizesCfg)){
44
+ lazySizesCfg[prop] = lazySizesDefaults[prop];
45
+ }
46
+ }
47
+ })();
48
+
49
+ if (!document || !document.getElementsByClassName) {
50
+ return {
51
+ init: function () {},
52
+ cfg: lazySizesCfg,
53
+ noSupport: true,
54
+ };
55
+ }
56
 
57
  var docElem = document.documentElement;
58
 
129
 
130
  var updatePolyfill = function (el, full){
131
  var polyfill;
132
+ if( !supportPicture && ( polyfill = (window.picturefill || lazySizesCfg.pf) ) ){
133
  if(full && full.src && !el[_getAttribute]('srcset')){
134
  el.setAttribute('srcset', full.src);
135
  }
146
  var getWidth = function(elem, parent, width){
147
  width = width || elem.offsetWidth;
148
 
149
+ while(width < lazySizesCfg.minSize && parent && !elem._lazysizesWidth){
150
  width = parent.offsetWidth;
151
  parent = parent.parentNode;
152
  }
211
  var throttle = function(fn){
212
  var running;
213
  var lastTime = 0;
214
+ var gDelay = lazySizesCfg.throttleDelay;
215
+ var rICTimeout = lazySizesCfg.ricTimeout;
216
  var run = function(){
217
  running = false;
218
  lastTime = Date.now();
222
  function(){
223
  requestIdleCallback(run, {timeout: rICTimeout});
224
 
225
+ if(rICTimeout !== lazySizesCfg.ricTimeout){
226
+ rICTimeout = lazySizesCfg.ricTimeout;
227
  }
228
  } :
229
  rAFIt(function(){
285
  };
286
  };
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  var loader = (function(){
289
  var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;
290
 
347
  beforeExpandVal, defaultExpand, preloadExpand, hFac;
348
  var lazyloadElems = lazysizes.elements;
349
 
350
+ if((loadMode = lazySizesCfg.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
351
 
352
  i = 0;
353
 
354
  lowRuns++;
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  for(; i < eLlen; i++){
357
 
358
  if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
359
 
360
+ if(!supportScroll || (lazysizes.prematureUnveil && lazysizes.prematureUnveil(lazyloadElems[i]))){unveilElement(lazyloadElems[i]);continue;}
361
 
362
  if(!(elemExpandVal = lazyloadElems[i][_getAttribute]('data-expand')) || !(elemExpand = elemExpandVal * 1)){
363
  elemExpand = currentExpand;
364
  }
365
 
366
+ if (!defaultExpand) {
367
+ defaultExpand = (!lazySizesCfg.expand || lazySizesCfg.expand < 1) ?
368
+ docElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370 :
369
+ lazySizesCfg.expand;
370
+
371
+ lazysizes._defEx = defaultExpand;
372
+
373
+ preloadExpand = defaultExpand * lazySizesCfg.expFactor;
374
+ hFac = lazySizesCfg.hFac;
375
+ isBodyHidden = null;
376
+
377
+ if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden){
378
+ currentExpand = preloadExpand;
379
+ lowRuns = 0;
380
+ } else if(loadMode > 1 && lowRuns > 1 && isLoading < 6){
381
+ currentExpand = defaultExpand;
382
+ } else {
383
+ currentExpand = shrinkExpand;
384
+ }
385
+ }
386
+
387
  if(beforeExpandVal !== elemExpand){
388
  eLvW = innerWidth + (elemExpand * hFac);
389
  elvH = innerHeight + elemExpand;
398
  (eLright = rect.right) >= elemNegativeExpand * hFac &&
399
  (eLleft = rect.left) <= eLvW &&
400
  (eLbottom || eLright || eLleft || eLtop) &&
401
+ (lazySizesCfg.loadHidden || isVisible(lazyloadElems[i])) &&
402
  ((isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4)) || isNestedVisible(lazyloadElems[i], elemExpand))){
403
  unveilElement(lazyloadElems[i]);
404
  loadedSomething = true;
405
  if(isLoading > 9){break;}
406
  } else if(!loadedSomething && isCompleted && !autoLoadElem &&
407
  isLoading < 4 && lowRuns < 4 && loadMode > 2 &&
408
+ (preloadElems[0] || lazySizesCfg.preloadAfterLoad) &&
409
+ (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesCfg.sizesAttr) != 'auto')))){
410
  autoLoadElem = preloadElems[0] || lazyloadElems[i];
411
  }
412
  }
428
  }
429
 
430
  resetPreloading(e);
431
+ addClass(elem, lazySizesCfg.loadedClass);
432
+ removeClass(elem, lazySizesCfg.loadingClass);
433
  addRemoveLoadEvents(elem, rafSwitchLoadingClass);
434
  triggerEvent(elem, 'lazyloaded');
435
  };
449
  var handleSources = function(source){
450
  var customMedia;
451
 
452
+ var sourceSrcset = source[_getAttribute](lazySizesCfg.srcsetAttr);
453
 
454
+ if( (customMedia = lazySizesCfg.customMedia[source[_getAttribute]('data-media') || source[_getAttribute]('media')]) ){
455
  source.setAttribute('media', customMedia);
456
  }
457
 
467
 
468
  if(sizes){
469
  if(isAuto){
470
+ addClass(elem, lazySizesCfg.autosizesClass);
471
  } else {
472
  elem.setAttribute('sizes', sizes);
473
  }
474
  }
475
 
476
+ srcset = elem[_getAttribute](lazySizesCfg.srcsetAttr);
477
+ src = elem[_getAttribute](lazySizesCfg.srcAttr);
478
 
479
  if(isImg) {
480
  parent = elem.parentNode;
485
 
486
  event = {target: elem};
487
 
488
+ addClass(elem, lazySizesCfg.loadingClass);
489
 
490
  if(firesLoad){
491
  clearTimeout(resetPreloadingTimer);
515
  if(elem._lazyRace){
516
  delete elem._lazyRace;
517
  }
518
+ removeClass(elem, lazySizesCfg.lazyClass);
519
 
520
  rAF(function(){
521
  // Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015)
522
+ var isLoaded = elem.complete && elem.naturalWidth > 1;
523
+
524
+ if( !firesLoad || isLoaded){
525
+ if (isLoaded) {
526
+ addClass(elem, 'ls-is-cached');
527
+ }
528
  switchLoadingClass(event);
529
  elem._lazyCache = true;
530
  setTimeout(function(){
533
  }
534
  }, 9);
535
  }
536
+ if (elem.loading == 'lazy') {
537
+ isLoading--;
538
+ }
539
  }, true);
540
  });
541
 
542
  var unveilElement = function (elem){
543
+ if (elem._lazyRace) {return;}
544
  var detail;
545
 
546
  var isImg = regImg.test(elem.nodeName);
547
 
548
  //allow using sizes="auto", but don't use. it's invalid. Use data-sizes="auto" or a valid value for sizes instead (i.e.: sizes="80vw")
549
+ var sizes = isImg && (elem[_getAttribute](lazySizesCfg.sizesAttr) || elem[_getAttribute]('sizes'));
550
  var isAuto = sizes == 'auto';
551
 
552
+ if( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesCfg.errorClass) && hasClass(elem, lazySizesCfg.lazyClass)){return;}
553
 
554
  detail = triggerEvent(elem, 'lazyunveilread').detail;
555
 
563
  lazyUnveil(elem, detail, isAuto, sizes, isImg);
564
  };
565
 
566
+ var afterScroll = debounce(function(){
567
+ lazySizesCfg.loadMode = 3;
568
+ throttledCheckElements();
569
+ });
570
+
571
+ var altLoadmodeScrollListner = function(){
572
+ if(lazySizesCfg.loadMode == 3){
573
+ lazySizesCfg.loadMode = 2;
574
+ }
575
+ afterScroll();
576
+ };
577
+
578
  var onload = function(){
579
  if(isCompleted){return;}
580
  if(Date.now() - started < 999){
581
  setTimeout(onload, 999);
582
  return;
583
  }
584
+
 
 
 
585
 
586
  isCompleted = true;
587
 
588
+ lazySizesCfg.loadMode = 3;
589
 
590
  throttledCheckElements();
591
 
592
+ addEventListener('scroll', altLoadmodeScrollListner, true);
 
 
 
 
 
593
  };
594
 
595
  return {
596
  _: function(){
597
  started = Date.now();
598
 
599
+ lazysizes.elements = document.getElementsByClassName(lazySizesCfg.lazyClass);
600
+ preloadElems = document.getElementsByClassName(lazySizesCfg.lazyClass + ' ' + lazySizesCfg.preloadClass);
601
 
602
  addEventListener('scroll', throttledCheckElements, true);
603
 
614
  addEventListener('hashchange', throttledCheckElements, true);
615
 
616
  //, 'fullscreenchange'
617
+ ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend'].forEach(function(name){
618
  document[_addEventListener](name, throttledCheckElements, true);
619
  });
620
 
634
  }
635
  },
636
  checkElems: throttledCheckElements,
637
+ unveil: unveilElement,
638
+ _aLSL: altLoadmodeScrollListner,
639
  };
640
  })();
641
 
695
 
696
  return {
697
  _: function(){
698
+ autosizesElems = document.getElementsByClassName(lazySizesCfg.autosizesClass);
699
  addEventListener('resize', debouncedUpdateElementsSizes);
700
  },
701
  checkElems: debouncedUpdateElementsSizes,
704
  })();
705
 
706
  var init = function(){
707
+ if(!init.i && document.getElementsByClassName){
708
  init.i = true;
709
  autoSizer._();
710
  loader._();
711
  }
712
  };
713
 
714
+ setTimeout(function(){
715
+ if(lazySizesCfg.init){
716
+ init();
717
+ }
718
+ });
719
+
720
  lazysizes = {
721
+ cfg: lazySizesCfg,
722
  autoSizer: autoSizer,
723
  loader: loader,
724
  init: init,
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 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(void 0===eio_lazy_vars)var eio_lazy_vars={exactdn_domain:".exactdn.com"};if(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 d=r.exec(e);if(d&&t<=d[1])return"bg-cover"===i?e.replace(r,"resize="+t+","+a):e.replace(r,"w="+t);var c=n.exec(s);if(c&&t<c[1])return"bg-cover"===i?e.replace(r,"resize="+t+","+a):s.replace(n,"fit="+t+","+a);if(!d&&!c&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===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?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){"use strict";if(!A.getElementsByClassName)return;var g,z,v=A.documentElement,n=i.Date,r=i.HTMLPictureElement,o="addEventListener",h="getAttribute",t=i[o],u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],d={},m=Array.prototype.forEach,c=function(e,t){return d[t]||(d[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),d[t].test(e[h]("class")||"")&&d[t]},p=function(e,t){c(e,t)||e.setAttribute("class",(e[h]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=c(e,t))&&e.setAttribute("class",(e[h]("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},C=function(e,t){var a;!r&&(a=i.picturefill||z.pf)?(t&&t.src&&!e[h]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},_=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<z.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},x=(B=[],R=[],L=B,N=function(){var e=L;for(L=B.length?R:B,M=!(W=!0);e.length;)e.shift()();W=!1},Q=function(e,t){W&&!t?e.apply(this,arguments):(L.push(e),M||(M=!0,(A.hidden?u:a)(N)))},Q._lsFlush=N,Q),e=function(a,e){return e?function(){x(a)}:function(){var e=this,t=arguments;x(function(){a.apply(e,t)})}},S=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))}};var W,M,B,R,L,N,Q;!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 z=i.lazySizesConfig||i.lazysizesConfig||{},t)e in z||(z[e]=t[e]);i.lazySizesConfig=z,u(function(){z.init&&D()})}();var P=(se=/^img$/i,le=/^iframe$/i,de="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ce=0,ue=0,fe=-1,Ae=function(e){ue--,(!e||ue<0||!e.target)&&(ue=0)},ge=function(e){return null==Z&&(Z="hidden"==_(A.body,"visibility")),Z||"hidden"!=_(e.parentNode,"visibility")&&"hidden"!=_(e,"visibility")},ze=function(e,t){var a,i=e,r=ge(e);for(V-=t,K+=t,X-=t,Y+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=v;)(r=0<(_(i,"opacity")||1))&&"visible"!=_(i,"overflow")&&(a=i.getBoundingClientRect(),r=Y>a.left&&X<a.right&&K>a.top-1&&V<a.bottom+1);return r},ve=function(){var e,t,a,i,r,n,o,s,l,d,c,u,f=g.elements;if((G=z.loadMode)&&ue<8&&(e=f.length)){for(t=0,fe++,d=!z.expand||z.expand<1?500<v.clientHeight&&500<v.clientWidth?500:370:z.expand,g._defEx=d,c=d*z.expFactor,u=z.hFac,Z=null,ce<c&&ue<1&&2<fe&&2<G&&!A.hidden?(ce=c,fe=0):ce=1<G&&1<fe&&ue<6?d:0;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(de)if((s=f[t][h]("data-expand"))&&(n=1*s)||(n=ce),l!==n&&(q=innerWidth+n*u,j=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(K=a.bottom)>=o&&(V=a.top)<=j&&(Y=a.right)>=o*u&&(X=a.left)<=q&&(K||Y||X||V)&&(z.loadHidden||ge(f[t]))&&(J&&ue<3&&!s&&(G<3||fe<4)||ze(f[t],n))){if(Ce(f[t]),r=!0,9<ue)break}else!r&&J&&!i&&ue<4&&fe<4&&2<G&&(I[0]||z.preloadAfterLoad)&&(I[0]||!s&&(K||Y||X||V||"auto"!=f[t][h](z.sizesAttr)))&&(i=I[0]||f[t]);else Ce(f[t]);i&&!r&&Ce(i)}},ee=ve,ae=0,ie=z.throttleDelay,re=z.ricTimeout,ne=function(){te=!1,ae=n.now(),ee()},oe=s&&49<re?function(){s(ne,{timeout:re}),re!==z.ricTimeout&&(re=z.ricTimeout)}:e(function(){u(ne)},!0),he=function(e){var t;(e=!0===e)&&(re=33),te||(te=!0,(t=ie-(n.now()-ae))<0&&(t=0),e||t<9?oe():u(oe,t))},me=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(Ae(e),p(t,z.loadedClass),y(t,z.loadingClass),b(t,ye),w(t,"lazyloaded"))},pe=e(me),ye=function(e){pe({target:e.target})},be=function(e){var t,a=e[h](z.srcsetAttr);(t=z.customMedia[e[h]("data-media")||e[h]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},we=e(function(e,t,a,i,r){var n,o,s,l,d,c;(d=w(e,"lazybeforeunveil",t)).defaultPrevented||(i&&(a?p(e,z.autosizesClass):e.setAttribute("sizes",i)),o=e[h](z.srcsetAttr),n=e[h](z.srcAttr),r&&(s=e.parentNode,l=s&&f.test(s.nodeName||"")),c=t.firesLoad||"src"in e&&(o||n||l),d={target:e},p(e,z.loadingClass),c&&(clearTimeout(O),O=u(Ae,2500),b(e,ye,!0)),l&&m.call(s.getElementsByTagName("source"),be),o?e.setAttribute("srcset",o):n&&!l&&(le.test(e.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(e,n):e.src=n),r&&(o||l)&&C(e,{src:n})),e._lazyRace&&delete e._lazyRace,y(e,z.lazyClass),x(function(){(!c||e.complete&&1<e.naturalWidth)&&(me(d),e._lazyCache=!0,u(function(){"_lazyCache"in e&&delete e._lazyCache},9))},!0)}),Ce=function(e){var t,a=se.test(e.nodeName),i=a&&(e[h](z.sizesAttr)||e[h]("sizes")),r="auto"==i;(!r&&J||!a||!e[h]("src")&&!e.srcset||e.complete||c(e,z.errorClass)||!c(e,z.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&k.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,ue++,we(e,t,r,i,a))},_e=function(){if(!J)if(n.now()-$<999)u(_e,999);else{var e=S(function(){z.loadMode=3,he()});J=!0,z.loadMode=3,he(),t("scroll",function(){3==z.loadMode&&(z.loadMode=2),e()},!0)}},{_:function(){$=n.now(),g.elements=A.getElementsByClassName(z.lazyClass),I=A.getElementsByClassName(z.lazyClass+" "+z.preloadClass),t("scroll",he,!0),t("resize",he,!0),i.MutationObserver?new MutationObserver(he).observe(v,{childList:!0,subtree:!0,attributes:!0}):(v[o]("DOMNodeInserted",he,!0),v[o]("DOMAttrModified",he,!0),setInterval(he,999)),t("hashchange",he,!0),["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(e){A[o](e,he,!0)}),/d$|^c/.test(A.readyState)?_e():(t("load",_e),A[o]("DOMContentLoaded",he),u(_e,2e4)),g.elements.length?(ve(),x._lsFlush()):he()},checkElems:he,unveil:Ce}),k=(H=e(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||C(e,a.detail)}),U=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&&H(e,r,i,a))},F=S(function(){var e,t=T.length;if(t)for(e=0;e<t;e++)U(T[e])}),{_:function(){T=A.getElementsByClassName(z.autosizesClass),t("resize",F)},checkElems:F,updateElem:U}),D=function(){D.i||(D.i=!0,k._(),P._())};var T,H,U,F;var I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,de,ce,ue,fe,Ae,ge,ze,ve,he,me,pe,ye,be,we,Ce,_e;return g={cfg:z,autoSizer:k,loader:P,init:D,uP:C,aC:p,rC:y,hC:c,fire:w,gW:E,rAF:x}}(e,e.document);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}(window),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(!a&&t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=1.25*t.clientWidth<t.naturalWidth,n=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"),d=t.getAttribute("data-src-webp");ewww_webp_supported&&d&&-1==l.search("webp=1")&&(l=d);var c=constrainSrc(l,o,s,"img");c&&l!=c&&t.setAttribute("data-src",c)}}if(ewww_webp_supported){if(a&&-1<a.search("webp=1"))return;if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if((l=t.getAttribute("data-src"))&&-1<l.search("webp=1"))return;if(!(d=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",d)}}),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(s,i,l){"use strict";var d,c;i.addEventListener&&(d=function(e,t){var a=i.createElement("img");a.onload=function(){a.onload=null,a.onerror=null,a=null,t()},a.onerror=a.onload,a.src=e,a&&a.complete&&a.onload&&a.onload()},addEventListener("lazybeforeunveil",function(e){var t,a,i;if(e.detail.instance==l&&!e.defaultPrevented){if("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 r=s.devicePixelRatio||1,n=Math.round(e.target.offsetWidth*r),o=Math.round(e.target.offsetHeight*r);t=s.lazySizes.hC(e.target,"wp-block-cover")?constrainSrc(t,n,o,"bg-cover"):s.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,n,o,"bg-cover"):constrainSrc(t,n,o,"bg"),e.detail.firesLoad=!0,d(t,function(){e.target.style.backgroundImage="url("+(c.test(t)?JSON.stringify(t):t)+")",e.detail.firesLoad=!1,l.fire(e.target,"_lazyloaded",{},!0,!0)})}(i=e.target.getAttribute("data-poster"))&&(e.detail.firesLoad=!0,d(i,function(){e.target.poster=i,e.detail.firesLoad=!1,l.fire(e.target,"_lazyloaded",{},!0,!0)}))}},!(c=/\(|\)|\s|'/)))});
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 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(void 0===eio_lazy_vars)var eio_lazy_vars={exactdn_domain:".exactdn.com"};if(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 d=r.exec(e);if(d&&t<=d[1])return"bg-cover"===i?e.replace(r,"resize="+t+","+a):e.replace(r,"w="+t);var c=n.exec(s);if(c&&t<c[1])return"bg-cover"===i?e.replace(r,"resize="+t+","+a):s.replace(n,"fit="+t+","+a);if(!d&&!c&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===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?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){"use strict";var g,z;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 z=i.lazySizesConfig||i.lazysizesConfig||{},t)e in z||(z[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:z,noSupport:!0};var v=A.documentElement,n=i.Date,r=i.HTMLPictureElement,o="addEventListener",h="getAttribute",e=i[o],u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],d={},m=Array.prototype.forEach,c=function(e,t){return d[t]||(d[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),d[t].test(e[h]("class")||"")&&d[t]},p=function(e,t){c(e,t)||e.setAttribute("class",(e[h]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=c(e,t))&&e.setAttribute("class",(e[h]("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},C=function(e,t){var a;!r&&(a=i.picturefill||z.pf)?(t&&t.src&&!e[h]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},_=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<z.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],Ce=[],_e=we,Ee=function(){var e=_e;for(_e=we.length?Ce:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(_e.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"==_(A.body,"visibility")),$||"hidden"!=_(e.parentNode,"visibility")&&"hidden"!=_(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!=v;)(r=0<(_(i,"opacity")||1))&&"visible"!=_(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},de=function(){var e,t,a,i,r,n,o,s,l,d,c,u,f=g.elements;if((T=z.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]))ve(f[t]);else if((s=f[t][h]("data-expand"))&&(n=1*s)||(n=ie),d||(d=!z.expand||z.expand<1?500<v.clientHeight&&500<v.clientWidth?500:370:z.expand,g._defEx=d,c=d*z.expFactor,u=z.hFac,$=null,ie<c&&re<1&&2<ne&&2<T&&!A.hidden?(ie=c,ne=0):ie=1<T&&1<ne&&re<6?d:0),l!==n&&(H=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)<=H&&(G||O||J||I)&&(z.loadHidden||se(f[t]))&&(k&&re<3&&!s&&(T<3||ne<4)||le(f[t],n))){if(ve(f[t]),r=!0,9<re)break}else!r&&k&&!i&&re<4&&ne<4&&2<T&&(P[0]||z.preloadAfterLoad)&&(P[0]||!s&&(G||O||J||I||"auto"!=f[t][h](z.sizesAttr)))&&(i=P[0]||f[t]);i&&!r&&ve(i)}},q=de,V=0,X=z.throttleDelay,Y=z.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==z.ricTimeout&&(Y=z.ricTimeout)}:t(function(){u(K)},!0),ce=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),p(t,z.loadedClass),y(t,z.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[h](z.srcsetAttr);(t=z.customMedia[e[h]("data-media")||e[h]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},ze=t(function(t,e,a,i,r){var n,o,s,l,d,c;(d=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?p(t,z.autosizesClass):t.setAttribute("sizes",i)),o=t[h](z.srcsetAttr),n=t[h](z.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),c=e.firesLoad||"src"in t&&(o||n||l),d={target:t},p(t,z.loadingClass),c&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&m.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)&&C(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,z.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;c&&!e||(e&&p(t,"ls-is-cached"),ue(d),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ve=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[h](z.sizesAttr)||e[h]("sizes")),r="auto"==i;(!r&&k||!a||!e[h]("src")&&!e.srcset||e.complete||c(e,z.errorClass)||!c(e,z.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&B.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,ze(e,t,r,i,a))}},he=x(function(){z.loadMode=3,ce()}),me=function(){3==z.loadMode&&(z.loadMode=2),he()},pe=function(){k||(n.now()-U<999?u(pe,999):(k=!0,z.loadMode=3,ce(),e("scroll",me,!0)))},{_:function(){U=n.now(),g.elements=A.getElementsByClassName(z.lazyClass),P=A.getElementsByClassName(z.lazyClass+" "+z.preloadClass),e("scroll",ce,!0),e("resize",ce,!0),i.MutationObserver?new MutationObserver(ce).observe(v,{childList:!0,subtree:!0,attributes:!0}):(v[o]("DOMNodeInserted",ce,!0),v[o]("DOMAttrModified",ce,!0),setInterval(ce,999)),e("hashchange",ce,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,ce,!0)}),/d$|^c/.test(A.readyState)?pe():(e("load",pe),A[o]("DOMContentLoaded",ce),u(pe,2e4)),g.elements.length?(de(),S._lsFlush()):ce()},checkElems:ce,unveil:ve,_aLSL:me}),B=(L=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||C(e,a.detail)}),N=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&&L(e,r,i,a))},Q=x(function(){var e,t=R.length;if(t)for(e=0;e<t;e++)N(R[e])}),{_:function(){R=A.getElementsByClassName(z.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:N}),M=function(){!M.i&&A.getElementsByClassName&&(M.i=!0,B._(),W._())};var R,L,N,Q;var P,k,D,T,U,H,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,de,ce,ue,fe,Ae,ge,ze,ve,he,me,pe;var ye,be,we,Ce,_e,Ee,Se;return u(function(){z.init&&M()}),g={cfg:z,autoSizer:B,loader:W,init:M,uP:C,aC:p,rC:y,hC:c,fire:w,gW:E,rAF:S}}(e,e.document);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(!a&&t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=1.25*t.clientWidth<t.naturalWidth,n=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"),d=t.getAttribute("data-src-webp");ewww_webp_supported&&d&&-1==l.search("webp=1")&&(l=d);var c=constrainSrc(l,o,s,"img");c&&l!=c&&t.setAttribute("data-src",c)}}if(ewww_webp_supported){if(a&&-1<a.search("webp=1"))return;if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if((l=t.getAttribute("data-src"))&&-1<l.search("webp=1"))return;if(!(d=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",d)}}),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(s,i,l){"use strict";var d,c;i.addEventListener&&(d=function(e,t){var a=i.createElement("img");a.onload=function(){a.onload=null,a.onerror=null,a=null,t()},a.onerror=a.onload,a.src=e,a&&a.complete&&a.onload&&a.onload()},addEventListener("lazybeforeunveil",function(e){var t,a,i;if(e.detail.instance==l&&!e.defaultPrevented){if("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 r=s.devicePixelRatio||1,n=Math.round(e.target.offsetWidth*r),o=Math.round(e.target.offsetHeight*r);t=s.lazySizes.hC(e.target,"wp-block-cover")?constrainSrc(t,n,o,"bg-cover"):s.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,n,o,"bg-cover"):constrainSrc(t,n,o,"bg"),e.detail.firesLoad=!0,d(t,function(){e.target.style.backgroundImage="url("+(c.test(t)?JSON.stringify(t):t)+")",e.detail.firesLoad=!1,l.fire(e.target,"_lazyloaded",{},!0,!0)})}(i=e.target.getAttribute("data-poster"))&&(e.detail.firesLoad=!0,d(i,function(){e.target.poster=i,e.detail.firesLoad=!1,l.fire(e.target,"_lazyloaded",{},!0,!0)}))}},!(c=/\(|\)|\s|'/)))});
includes/load_webp.js CHANGED
@@ -480,7 +480,56 @@ function check_webp_feature(feature, callback) {
480
  function ewwwLoadImages(ewww_webp_supported) {
481
  var attr_prefix = 'data-';
482
  function ewwwCopyAttrs(ewww_nscript, ewww_img) {
483
- var attrs = ['align','alt','border','crossorigin','height','hspace','ismap','longdesc','usemap','vspace','width','accesskey','class','contenteditable','contextmenu','dir','draggable','dropzone','hidden','id','lang','spellcheck','style','tabindex','title','translate','sizes','data-caption','data-attachment-id','data-permalink','data-orig-size','data-comments-opened','data-image-meta','data-image-title','data-image-description','data-event-trigger','data-highlight-color','data-highlight-opacity','data-highlight-border-color','data-highlight-border-width','data-highlight-border-opacity','data-no-lazy','data-lazy','data-large_image_width','data-large_image_height'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  for (var i = 0, len = attrs.length; i < len; i++) {
485
  ewwwAttr(ewww_img, attrs[i], ewww_nscript.getAttribute(attr_prefix + attrs[i]));
486
  }
480
  function ewwwLoadImages(ewww_webp_supported) {
481
  var attr_prefix = 'data-';
482
  function ewwwCopyAttrs(ewww_nscript, ewww_img) {
483
+ var attrs = [
484
+ 'accesskey',
485
+ 'align',
486
+ 'alt',
487
+ 'border',
488
+ 'class',
489
+ 'contenteditable',
490
+ 'contextmenu',
491
+ 'crossorigin',
492
+ 'dir',
493
+ 'draggable',
494
+ 'dropzone',
495
+ 'height',
496
+ 'hidden',
497
+ 'hspace',
498
+ 'id',
499
+ 'ismap',
500
+ 'lang',
501
+ 'longdesc',
502
+ 'sizes',
503
+ 'spellcheck',
504
+ 'style',
505
+ 'tabindex',
506
+ 'title',
507
+ 'translate',
508
+ 'usemap',
509
+ 'vspace',
510
+ 'width',
511
+ 'data-attachment-id',
512
+ 'data-caption',
513
+ 'data-comments-opened',
514
+ 'data-event-trigger',
515
+ 'data-height',
516
+ 'data-highlight-color',
517
+ 'data-highlight-border-color',
518
+ 'data-highlight-border-opacity',
519
+ 'data-highlight-border-width',
520
+ 'data-highlight-opacity',
521
+ 'data-image-meta',
522
+ 'data-image-title',
523
+ 'data-image-description',
524
+ 'data-large_image_width',
525
+ 'data-large_image_height',
526
+ 'data-lazy',
527
+ 'data-lazy-type',
528
+ 'data-no-lazy',
529
+ 'data-orig-size',
530
+ 'data-permalink',
531
+ 'data-width',
532
+ ];
533
  for (var i = 0, len = attrs.length; i < len; i++) {
534
  ewwwAttr(ewww_img, attrs[i], ewww_nscript.getAttribute(attr_prefix + attrs[i]));
535
  }
includes/load_webp.min.js CHANGED
@@ -1 +1 @@
1
- var Arrive=function(c,e,d){"use strict";if(c.MutationObserver&&"undefined"!=typeof HTMLElement){var r,t,a=0,u=(r=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&r.call(e,t)},addMethod:function(e,t,r){var a=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof a?a.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var r,a=0;r=e[a];a++)r&&r.callback&&r.callback.call(r.elem,r.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,r,a){for(var i,n=0;i=e[n];n++)r(i,t,a)&&a.push({callback:t.callback,elem:i}),0<i.childNodes.length&&u.checkChildNodesRecursively(i.childNodes,t,r,a)},mergeArrays:function(e,t){var r,a={};for(r in e)e.hasOwnProperty(r)&&(a[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(a[r]=t[r]);return a},toElementsArray:function(e){return void 0===e||"number"==typeof e.length&&e!==c||(e=[e]),e}}),w=((t=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}).prototype.addEvent=function(e,t,r,a){var i={target:e,selector:t,options:r,callback:a,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},t.prototype.removeEvent=function(e){for(var t,r=this._eventsBucket.length-1;t=this._eventsBucket[r];r--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var a=this._eventsBucket.splice(r,1);a&&a.length&&(a[0].callback=null)}},t.prototype.beforeAdding=function(e){this._beforeAdding=e},t.prototype.beforeRemoving=function(e){this._beforeRemoving=e},t),l=function(i,n){var l=new w,o=this,s={fireOnAttributesModification:!1};return l.beforeAdding(function(t){var e,r=t.target;r!==c.document&&r!==c||(r=document.getElementsByTagName("html")[0]),e=new MutationObserver(function(e){n.call(this,e,t)});var a=i(t.options);e.observe(r,a),t.observer=e,t.me=o}),l.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,r){t=u.mergeArrays(s,t);for(var a=u.toElementsArray(this),i=0;i<a.length;i++)l.addEvent(a[i],e,t,r)},this.unbindEvent=function(){var r=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<r.length;t++)if(this===d||e.target===r[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(r){var e,a=u.toElementsArray(this),i=r;e="function"==typeof r?function(e){for(var t=0;t<a.length;t++)if((this===d||e.target===a[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<a.length;t++)if((this===d||e.target===a[t])&&e.selector===r)return!0;return!1},l.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(r,a){var i=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===d||e.target===i[t])&&e.selector===r&&e.callback===a)return!0;return!1})},this},i=new function(){var s={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,r){return!(!u.matchesSelector(e,t.selector)||(e._id===d&&(e._id=a++),-1!=t.firedElems.indexOf(e._id))||(t.firedElems.push(e._id),0))}var c=(i=new l(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,r=e.target,a=[];null!==t&&0<t.length?u.checkChildNodesRecursively(t,i,n,a):"attributes"===e.type&&n(r,i)&&a.push({callback:i.callback,elem:r}),u.callCallbacks(a,i)})})).bindEvent;return i.bindEvent=function(e,t,r){t=void 0===r?(r=t,s):u.mergeArrays(s,t);var a=u.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<a.length;n++)for(var l=a[n].querySelectorAll(e),o=0;o<l.length;o++)i.push({callback:r,elem:l[o]});if(t.onceOnly&&i.length)return r.call(i[0].elem,i[0].elem);setTimeout(u.callCallbacks,1,i)}c.call(this,e,t,r)},i},o=new function(){var a={};function i(e,t){return u.matchesSelector(e,t.selector)}var n=(o=new l(function(){return{childList:!0,subtree:!0}},function(e,a){e.forEach(function(e){var t=e.removedNodes,r=[];null!==t&&0<t.length&&u.checkChildNodesRecursively(t,a,i,r),u.callCallbacks(r,a)})})).bindEvent;return o.bindEvent=function(e,t,r){t=void 0===r?(r=t,a):u.mergeArrays(a,t),n.call(this,e,t,r)},o};e&&g(e.fn),g(HTMLElement.prototype),g(NodeList.prototype),g(HTMLCollection.prototype),g(HTMLDocument.prototype),g(Window.prototype);var n={};return s(i,n,"unbindAllArrive"),s(o,n,"unbindAllLeave"),n}function s(e,t,r){u.addMethod(t,r,e.unbindEvent),u.addMethod(t,r,e.unbindEventWithSelectorOrCallback),u.addMethod(t,r,e.unbindEventWithSelectorAndCallback)}function g(e){e.arrive=i.bindEvent,s(i,e,"unbindArrive"),e.leave=o.bindEvent,s(o,e,"unbindLeave")}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);function check_webp_feature(e,t){var r=new Image;r.onload=function(){var e=0<r.width&&0<r.height;t(e)},r.onerror=function(){t(!1)},r.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function ewwwLoadImages(e){var n="data-";function t(e,t){for(var r=["align","alt","border","crossorigin","height","hspace","ismap","longdesc","usemap","vspace","width","accesskey","class","contenteditable","contextmenu","dir","draggable","dropzone","hidden","id","lang","spellcheck","style","tabindex","title","translate","sizes","data-caption","data-attachment-id","data-permalink","data-orig-size","data-comments-opened","data-image-meta","data-image-title","data-image-description","data-event-trigger","data-highlight-color","data-highlight-opacity","data-highlight-border-color","data-highlight-border-width","data-highlight-border-opacity","data-no-lazy","data-lazy","data-large_image_width","data-large_image_height"],a=0,i=r.length;a<i;a++)ewwwAttr(t,r[a],e.getAttribute(n+r[a]));return t}if(e){for(var r=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),a=0,i=r.length;a<i;a++)ewwwAttr(r[a],"data-src",r[a].getAttribute("data-webp")),ewwwAttr(r[a],"data-thumbnail",r[a].getAttribute("data-webp-thumbnail"));for(a=0,i=(o=document.querySelectorAll(".rev_slider ul li")).length;a<i;a++){ewwwAttr(o[a],"data-thumb",o[a].getAttribute("data-webp-thumb"));for(var l=1;l<11;)ewwwAttr(o[a],"data-param"+l,o[a].getAttribute("data-webp-param"+l)),l++}var o;for(a=0,i=(o=document.querySelectorAll(".rev_slider img")).length;a<i;a++)ewwwAttr(o[a],"data-lazyload",o[a].getAttribute("data-webp-lazyload"));var s=document.querySelectorAll("div.woocommerce-product-gallery__image");for(a=0,i=s.length;a<i;a++)ewwwAttr(s[a],"data-thumb",s[a].getAttribute("data-webp-thumb"))}var c=document.querySelectorAll("videos");for(a=0,i=c.length;a<i;a++)ewwwAttr(c[a],"poster",e?c[a].getAttribute("data-poster-webp"):c[a].getAttribute("data-poster-image"));var d=document.querySelectorAll("img.ewww_webp_lazy_load");for(a=0,i=d.length;a<i;a++){if(e){ewwwAttr(d[a],"data-lazy-srcset",d[a].getAttribute("data-lazy-srcset-webp")),ewwwAttr(d[a],"data-srcset",d[a].getAttribute("data-srcset-webp")),ewwwAttr(d[a],"data-lazy-src",d[a].getAttribute("data-lazy-src-webp")),ewwwAttr(d[a],"data-src",d[a].getAttribute("data-src-webp")),ewwwAttr(d[a],"data-orig-file",d[a].getAttribute("data-webp-orig-file")),ewwwAttr(d[a],"data-medium-file",d[a].getAttribute("data-webp-medium-file")),ewwwAttr(d[a],"data-large-file",d[a].getAttribute("data-webp-large-file"));var u=d[a].getAttribute("srcset");null!=u&&!1!==u&&u.includes("R0lGOD")&&ewwwAttr(d[a],"src",d[a].getAttribute("data-lazy-src-webp"))}d[a].className=d[a].className.replace(/\bewww_webp_lazy_load\b/,"")}var w=document.querySelectorAll(".ewww_webp");for(a=0,i=w.length;a<i;a++){var g=document.createElement("img");e?(ewwwAttr(g,"src",w[a].getAttribute("data-webp")),ewwwAttr(g,"srcset",w[a].getAttribute("data-srcset-webp")),ewwwAttr(g,"data-orig-file",w[a].getAttribute("data-orig-file")),ewwwAttr(g,"data-orig-file",w[a].getAttribute("data-webp-orig-file")),ewwwAttr(g,"data-medium-file",w[a].getAttribute("data-medium-file")),ewwwAttr(g,"data-medium-file",w[a].getAttribute("data-webp-medium-file")),ewwwAttr(g,"data-large-file",w[a].getAttribute("data-large-file")),ewwwAttr(g,"data-large-file",w[a].getAttribute("data-webp-large-file")),ewwwAttr(g,"data-large_image",w[a].getAttribute("data-large_image")),ewwwAttr(g,"data-large_image",w[a].getAttribute("data-webp-large_image")),ewwwAttr(g,"data-src",w[a].getAttribute("data-src")),ewwwAttr(g,"data-src",w[a].getAttribute("data-webp-src"))):(ewwwAttr(g,"src",w[a].getAttribute("data-img")),ewwwAttr(g,"srcset",w[a].getAttribute("data-srcset-img")),ewwwAttr(g,"data-orig-file",w[a].getAttribute("data-orig-file")),ewwwAttr(g,"data-medium-file",w[a].getAttribute("data-medium-file")),ewwwAttr(g,"data-large-file",w[a].getAttribute("data-large-file")),ewwwAttr(g,"data-large_image",w[a].getAttribute("data-large_image")),ewwwAttr(g,"data-src",w[a].getAttribute("data-src"))),g=t(w[a],g),w[a].parentNode.insertBefore(g,w[a].nextSibling),w[a].className=w[a].className.replace(/\bewww_webp\b/,"")}window.jQuery&&jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)});var t=0,r=setInterval(function(){"undefined"!=typeof galleries&&(ewwwNggParseGalleries(e),clearInterval(r)),1e3<(t+=25)&&clearInterval(r)},25)}function ewwwAttr(e,t,r){null!=r&&!1!==r&&e.setAttribute(t,r)}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var r=galleries[t];galleries[t].images_list=ewwwNggParseImageList(r.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var r=$(e).data("id");return galleries["gallery_"+r].images_list=ewwwNggParseImageList(galleries["gallery_"+r].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var r=e[t];if(void 0!==r["image-webp"]&&(e[t].image=r["image-webp"],delete e[t]["image-webp"]),void 0!==r["thumb-webp"]&&(e[t].thumb=r["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==r.full_image_webp&&(e[t].full_image=r.full_image_webp,delete e[t].full_image_webp),void 0!==r.srcsets)for(var a in r.srcsets)nggSrcset=r.srcsets[a],void 0!==r.srcsets[a+"-webp"]&&(e[t].srcsets[a]=r.srcsets[a+"-webp"],delete e[t].srcsets[a+"-webp"]);if(void 0!==r.full_srcsets)for(var i in r.full_srcsets)nggFSrcset=r.full_srcsets[i],void 0!==r.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=r.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
1
+ var Arrive=function(c,e,d){"use strict";if(c.MutationObserver&&"undefined"!=typeof HTMLElement){var a,t,r=0,u=(a=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&a.call(e,t)},addMethod:function(e,t,a){var r=e[t];e[t]=function(){return a.length==arguments.length?a.apply(this,arguments):"function"==typeof r?r.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var a,r=0;a=e[r];r++)a&&a.callback&&a.callback.call(a.elem,a.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,a,r){for(var i,n=0;i=e[n];n++)a(i,t,r)&&r.push({callback:t.callback,elem:i}),0<i.childNodes.length&&u.checkChildNodesRecursively(i.childNodes,t,a,r)},mergeArrays:function(e,t){var a,r={};for(a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);for(a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);return r},toElementsArray:function(e){return void 0===e||"number"==typeof e.length&&e!==c||(e=[e]),e}}),w=((t=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}).prototype.addEvent=function(e,t,a,r){var i={target:e,selector:t,options:a,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},t.prototype.removeEvent=function(e){for(var t,a=this._eventsBucket.length-1;t=this._eventsBucket[a];a--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(a,1);r&&r.length&&(r[0].callback=null)}},t.prototype.beforeAdding=function(e){this._beforeAdding=e},t.prototype.beforeRemoving=function(e){this._beforeRemoving=e},t),l=function(i,n){var l=new w,o=this,s={fireOnAttributesModification:!1};return l.beforeAdding(function(t){var e,a=t.target;a!==c.document&&a!==c||(a=document.getElementsByTagName("html")[0]),e=new MutationObserver(function(e){n.call(this,e,t)});var r=i(t.options);e.observe(a,r),t.observer=e,t.me=o}),l.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,a){t=u.mergeArrays(s,t);for(var r=u.toElementsArray(this),i=0;i<r.length;i++)l.addEvent(r[i],e,t,a)},this.unbindEvent=function(){var a=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<a.length;t++)if(this===d||e.target===a[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(a){var e,r=u.toElementsArray(this),i=a;e="function"==typeof a?function(e){for(var t=0;t<r.length;t++)if((this===d||e.target===r[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<r.length;t++)if((this===d||e.target===r[t])&&e.selector===a)return!0;return!1},l.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(a,r){var i=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===d||e.target===i[t])&&e.selector===a&&e.callback===r)return!0;return!1})},this},i=new function(){var s={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,a){return!(!u.matchesSelector(e,t.selector)||(e._id===d&&(e._id=r++),-1!=t.firedElems.indexOf(e._id))||(t.firedElems.push(e._id),0))}var c=(i=new l(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,a=e.target,r=[];null!==t&&0<t.length?u.checkChildNodesRecursively(t,i,n,r):"attributes"===e.type&&n(a,i)&&r.push({callback:i.callback,elem:a}),u.callCallbacks(r,i)})})).bindEvent;return i.bindEvent=function(e,t,a){t=void 0===a?(a=t,s):u.mergeArrays(s,t);var r=u.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<r.length;n++)for(var l=r[n].querySelectorAll(e),o=0;o<l.length;o++)i.push({callback:a,elem:l[o]});if(t.onceOnly&&i.length)return a.call(i[0].elem,i[0].elem);setTimeout(u.callCallbacks,1,i)}c.call(this,e,t,a)},i},o=new function(){var r={};function i(e,t){return u.matchesSelector(e,t.selector)}var n=(o=new l(function(){return{childList:!0,subtree:!0}},function(e,r){e.forEach(function(e){var t=e.removedNodes,a=[];null!==t&&0<t.length&&u.checkChildNodesRecursively(t,r,i,a),u.callCallbacks(a,r)})})).bindEvent;return o.bindEvent=function(e,t,a){t=void 0===a?(a=t,r):u.mergeArrays(r,t),n.call(this,e,t,a)},o};e&&g(e.fn),g(HTMLElement.prototype),g(NodeList.prototype),g(HTMLCollection.prototype),g(HTMLDocument.prototype),g(Window.prototype);var n={};return s(i,n,"unbindAllArrive"),s(o,n,"unbindAllLeave"),n}function s(e,t,a){u.addMethod(t,a,e.unbindEvent),u.addMethod(t,a,e.unbindEventWithSelectorOrCallback),u.addMethod(t,a,e.unbindEventWithSelectorAndCallback)}function g(e){e.arrive=i.bindEvent,s(i,e,"unbindArrive"),e.leave=o.bindEvent,s(o,e,"unbindLeave")}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);function check_webp_feature(e,t){var a=new Image;a.onload=function(){var e=0<a.width&&0<a.height;t(e)},a.onerror=function(){t(!1)},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function ewwwLoadImages(e){var n="data-";function t(e,t){for(var a=["accesskey","align","alt","border","class","contenteditable","contextmenu","crossorigin","dir","draggable","dropzone","height","hidden","hspace","id","ismap","lang","longdesc","sizes","spellcheck","style","tabindex","title","translate","usemap","vspace","width","data-attachment-id","data-caption","data-comments-opened","data-event-trigger","data-height","data-highlight-color","data-highlight-border-color","data-highlight-border-opacity","data-highlight-border-width","data-highlight-opacity","data-image-meta","data-image-title","data-image-description","data-large_image_width","data-large_image_height","data-lazy","data-lazy-type","data-no-lazy","data-orig-size","data-permalink","data-width"],r=0,i=a.length;r<i;r++)ewwwAttr(t,a[r],e.getAttribute(n+a[r]));return t}if(e){for(var a=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),r=0,i=a.length;r<i;r++)ewwwAttr(a[r],"data-src",a[r].getAttribute("data-webp")),ewwwAttr(a[r],"data-thumbnail",a[r].getAttribute("data-webp-thumbnail"));for(r=0,i=(o=document.querySelectorAll(".rev_slider ul li")).length;r<i;r++){ewwwAttr(o[r],"data-thumb",o[r].getAttribute("data-webp-thumb"));for(var l=1;l<11;)ewwwAttr(o[r],"data-param"+l,o[r].getAttribute("data-webp-param"+l)),l++}var o;for(r=0,i=(o=document.querySelectorAll(".rev_slider img")).length;r<i;r++)ewwwAttr(o[r],"data-lazyload",o[r].getAttribute("data-webp-lazyload"));var s=document.querySelectorAll("div.woocommerce-product-gallery__image");for(r=0,i=s.length;r<i;r++)ewwwAttr(s[r],"data-thumb",s[r].getAttribute("data-webp-thumb"))}var c=document.querySelectorAll("videos");for(r=0,i=c.length;r<i;r++)ewwwAttr(c[r],"poster",e?c[r].getAttribute("data-poster-webp"):c[r].getAttribute("data-poster-image"));var d=document.querySelectorAll("img.ewww_webp_lazy_load");for(r=0,i=d.length;r<i;r++){if(e){ewwwAttr(d[r],"data-lazy-srcset",d[r].getAttribute("data-lazy-srcset-webp")),ewwwAttr(d[r],"data-srcset",d[r].getAttribute("data-srcset-webp")),ewwwAttr(d[r],"data-lazy-src",d[r].getAttribute("data-lazy-src-webp")),ewwwAttr(d[r],"data-src",d[r].getAttribute("data-src-webp")),ewwwAttr(d[r],"data-orig-file",d[r].getAttribute("data-webp-orig-file")),ewwwAttr(d[r],"data-medium-file",d[r].getAttribute("data-webp-medium-file")),ewwwAttr(d[r],"data-large-file",d[r].getAttribute("data-webp-large-file"));var u=d[r].getAttribute("srcset");null!=u&&!1!==u&&u.includes("R0lGOD")&&ewwwAttr(d[r],"src",d[r].getAttribute("data-lazy-src-webp"))}d[r].className=d[r].className.replace(/\bewww_webp_lazy_load\b/,"")}var w=document.querySelectorAll(".ewww_webp");for(r=0,i=w.length;r<i;r++){var g=document.createElement("img");e?(ewwwAttr(g,"src",w[r].getAttribute("data-webp")),ewwwAttr(g,"srcset",w[r].getAttribute("data-srcset-webp")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-webp-orig-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-webp-medium-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-webp-large-file")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-large_image")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-webp-large_image")),ewwwAttr(g,"data-src",w[r].getAttribute("data-src")),ewwwAttr(g,"data-src",w[r].getAttribute("data-webp-src"))):(ewwwAttr(g,"src",w[r].getAttribute("data-img")),ewwwAttr(g,"srcset",w[r].getAttribute("data-srcset-img")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-large_image")),ewwwAttr(g,"data-src",w[r].getAttribute("data-src"))),g=t(w[r],g),w[r].parentNode.insertBefore(g,w[r].nextSibling),w[r].className=w[r].className.replace(/\bewww_webp\b/,"")}window.jQuery&&jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)});var t=0,a=setInterval(function(){"undefined"!=typeof galleries&&(ewwwNggParseGalleries(e),clearInterval(a)),1e3<(t+=25)&&clearInterval(a)},25)}function ewwwAttr(e,t,a){null!=a&&!1!==a&&e.setAttribute(t,a)}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var a=galleries[t];galleries[t].images_list=ewwwNggParseImageList(a.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var a=$(e).data("id");return galleries["gallery_"+a].images_list=ewwwNggParseImageList(galleries["gallery_"+a].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var a=e[t];if(void 0!==a["image-webp"]&&(e[t].image=a["image-webp"],delete e[t]["image-webp"]),void 0!==a["thumb-webp"]&&(e[t].thumb=a["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==a.full_image_webp&&(e[t].full_image=a.full_image_webp,delete e[t].full_image_webp),void 0!==a.srcsets)for(var r in a.srcsets)nggSrcset=a.srcsets[r],void 0!==a.srcsets[r+"-webp"]&&(e[t].srcsets[r]=a.srcsets[r+"-webp"],delete e[t].srcsets[r+"-webp"]);if(void 0!==a.full_srcsets)for(var i in a.full_srcsets)nggFSrcset=a.full_srcsets[i],void 0!==a.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=a.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: nosilver4u
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
4
  Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
5
  Requires at least: 5.0
6
- Tested up to: 5.2
7
  Requires PHP: 5.6
8
- Stable tag: 4.9.3
9
  License: GPLv3
10
 
11
  Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
@@ -173,6 +173,18 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images
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
  = 4.9.3 =
177
  * fixed: ExactDN incorrectly scales Elementor background images rather than cropping
178
  * fixed: ExactDN cannot work with Divi/Elementor background images due to use of external CSS files
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
4
  Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
5
  Requires at least: 5.0
6
+ Tested up to: 5.3
7
  Requires PHP: 5.6
8
+ Stable tag: 5.0.0
9
  License: GPLv3
10
 
11
  Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
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.0.0 =
177
+ * added: use native lazy load attributes to supplement lazy loader and make placeholders more efficient
178
+ * added: GCS sub-folder rewriting with ExactDN for cleaner URLs
179
+ * added: option to optimize original versions of scaled images for WP 5.3
180
+ * added: ability to erase optimization history from Tools page
181
+ * changed: define EWWWIO_WPLR_AUTO (any value) to enable auto-optimize on images from WP/LR Sync
182
+ * changed: thumbnails could be converted even if original was not
183
+ * changed: Show Optimized Images table moved to Tools menu
184
+ * fixed: full-size image optimization not deferred if scaled by WP 5.3
185
+ * fixed: data-width and data-height attributes missing when JS WebP active
186
+ * security: rewrote escapeshellarg() wrapper to be more secure
187
+
188
  = 4.9.3 =
189
  * fixed: ExactDN incorrectly scales Elementor background images rather than cropping
190
  * fixed: ExactDN cannot work with Divi/Elementor background images due to use of external CSS files
tests/test-convert.php CHANGED
@@ -76,7 +76,7 @@ class EWWWIO_Convert_Tests extends WP_UnitTestCase {
76
  $_REQUEST['ewww_force'] = 1;
77
  $filename = $original . ".jpg";
78
  copy( $original, $filename );
79
- $results = ewww_image_optimizer( $filename, 1 );
80
  return $results;
81
  }
82
 
@@ -92,7 +92,7 @@ class EWWWIO_Convert_Tests extends WP_UnitTestCase {
92
  $_REQUEST['ewww_force'] = 1;
93
  $filename = $original . ".png";
94
  copy( $original, $filename );
95
- $results = ewww_image_optimizer( $filename, 1 );
96
  return $results;
97
  }
98
 
@@ -108,7 +108,7 @@ class EWWWIO_Convert_Tests extends WP_UnitTestCase {
108
  $_REQUEST['ewww_force'] = 1;
109
  $filename = $original . ".gif";
110
  copy( $original, $filename );
111
- $results = ewww_image_optimizer( $filename, 1 );
112
  return $results;
113
  }
114
 
76
  $_REQUEST['ewww_force'] = 1;
77
  $filename = $original . ".jpg";
78
  copy( $original, $filename );
79
+ $results = ewww_image_optimizer( $filename, 1, false, false, true );
80
  return $results;
81
  }
82
 
92
  $_REQUEST['ewww_force'] = 1;
93
  $filename = $original . ".png";
94
  copy( $original, $filename );
95
+ $results = ewww_image_optimizer( $filename, 1, false, false, true );
96
  return $results;
97
  }
98
 
108
  $_REQUEST['ewww_force'] = 1;
109
  $filename = $original . ".gif";
110
  copy( $original, $filename );
111
+ $results = ewww_image_optimizer( $filename, 1, false, false, true );
112
  return $results;
113
  }
114
 
tests/test-utility.php CHANGED
@@ -62,7 +62,7 @@ class EWWWIO_Utility_Tests extends WP_UnitTestCase {
62
  * Tests that shell args get escaped properly (quotes and such).
63
  */
64
  function test_shellargesc() {
65
- $this->assertEquals( ewww_image_optimizer_escapeshellarg( "file'name" ), "'file'\"'\"'name'" );
66
  }
67
 
68
  /**
62
  * Tests that shell args get escaped properly (quotes and such).
63
  */
64
  function test_shellargesc() {
65
+ $this->assertEquals( ewww_image_optimizer_escapeshellarg( "file'name" ), "'file'\\''name'" );
66
  }
67
 
68
  /**
unique.php CHANGED
@@ -1218,6 +1218,33 @@ function ewww_image_optimizer_escapeshellcmd( $path ) {
1218
  return ( preg_replace( '/ /', '\ ', $path ) );
1219
  }
1220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1221
  /**
1222
  * Test the given binary to see if it returns a valid version string.
1223
  *
@@ -1869,7 +1896,11 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
1869
  case 'image/jpeg':
1870
  $png_size = 0;
1871
  // If jpg2png conversion is enabled, and this image is in the WordPress media library.
1872
- if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) && 1 === (int) $gallery_type ) || ! empty( $_REQUEST['ewww_convert'] ) ) {
 
 
 
 
1873
  // Generate the filename for a PNG:
1874
  // If this is a resize version.
1875
  if ( $converted ) {
@@ -2098,8 +2129,12 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2098
  $jpg_size = 0;
2099
  // Png2jpg conversion is turned on, and the image is in the WordPress media library.
2100
  // We check for transparency later, after optimization, because optipng might fix an empty alpha channel.
2101
- if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! empty( $_REQUEST['ewww_convert'] ) )
2102
- && 1 === (int) $gallery_type && ! $skip_lossy ) {
 
 
 
 
2103
  ewwwio_debug_message( 'PNG to JPG conversion turned on' );
2104
  $cloud_background = '';
2105
  $r = '';
@@ -2408,8 +2443,12 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2408
  break;
2409
  case 'image/gif':
2410
  // If gif2png is turned on, and the image is in the WordPress media library.
2411
- if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $_REQUEST['ewww_convert'] ) )
2412
- && 1 === (int) $gallery_type && ! ewww_image_optimizer_is_animated( $file ) ) {
 
 
 
 
2413
  // Generate the filename for a PNG:
2414
  // if this is a resize version...
2415
  if ( $converted ) {
1218
  return ( preg_replace( '/ /', '\ ', $path ) );
1219
  }
1220
 
1221
+ /**
1222
+ * Replacement for escapeshellarg() that won't kill non-ASCII characters.
1223
+ *
1224
+ * @param string $arg A value to sanitize/escape for commmand-line usage.
1225
+ * @return string The value after being escaped.
1226
+ */
1227
+ function ewww_image_optimizer_escapeshellarg( $arg ) {
1228
+ if ( PHP_OS === 'WINNT' ) {
1229
+ $safe_arg = str_replace( '%', ' ', $arg );
1230
+ $safe_arg = str_replace( '!', ' ', $safe_arg );
1231
+ $safe_arg = str_replace( '"', ' ', $safe_arg );
1232
+ return '"' . $safe_arg . '"';
1233
+ } elseif ( ewww_image_optimizer_function_exists( 'setlocale' ) ) {
1234
+ $current_locale = strtolower( setlocale( LC_CTYPE, 0 ) );
1235
+ if ( false === strpos( $current_locale, 'utf8' ) && false === strpos( $current_locale, 'utf-8' ) ) {
1236
+ $changed_local = true;
1237
+ ewwwio_debug_message( "setting locale, found $current_locale" );
1238
+ setlocale( LC_CTYPE, 'en_US.UTF-8' );
1239
+ }
1240
+ }
1241
+ $safe_arg = escapeshellarg( $arg );
1242
+ if ( ! empty( $changed_local ) ) {
1243
+ setlocale( LC_CTYPE, $current_locale );
1244
+ }
1245
+ return $safe_arg;
1246
+ }
1247
+
1248
  /**
1249
  * Test the given binary to see if it returns a valid version string.
1250
  *
1896
  case 'image/jpeg':
1897
  $png_size = 0;
1898
  // If jpg2png conversion is enabled, and this image is in the WordPress media library.
1899
+ if (
1900
+ 1 === (int) $gallery_type &&
1901
+ $fullsize &&
1902
+ ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) || ! empty( $_REQUEST['ewww_convert'] ) )
1903
+ ) {
1904
  // Generate the filename for a PNG:
1905
  // If this is a resize version.
1906
  if ( $converted ) {
2129
  $jpg_size = 0;
2130
  // Png2jpg conversion is turned on, and the image is in the WordPress media library.
2131
  // We check for transparency later, after optimization, because optipng might fix an empty alpha channel.
2132
+ if (
2133
+ 1 === (int) $gallery_type &&
2134
+ $fullsize &&
2135
+ ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! empty( $_REQUEST['ewww_convert'] ) ) &&
2136
+ ! $skip_lossy
2137
+ ) {
2138
  ewwwio_debug_message( 'PNG to JPG conversion turned on' );
2139
  $cloud_background = '';
2140
  $r = '';
2443
  break;
2444
  case 'image/gif':
2445
  // If gif2png is turned on, and the image is in the WordPress media library.
2446
+ if (
2447
+ 1 === (int) $gallery_type &&
2448
+ $fullsize &&
2449
+ ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $_REQUEST['ewww_convert'] ) ) &&
2450
+ ! ewww_image_optimizer_is_animated( $file )
2451
+ ) {
2452
  // Generate the filename for a PNG:
2453
  // if this is a resize version...
2454
  if ( $converted ) {