Version Description
- changed: folders to ignore setting applies to resizing also
- fixed: lazy load placeholders have inconsistent URLs with ExactDN
- fixed: bulk resume indicator gets stuck
- fixed: bulk scanning queue gets out of sync and skips images
- fixed: async processing does not handle memory limit specified in G (gigabytes)
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 4.6.3 |
Comparing to | |
See all releases |
Code changes from version 4.6.2 to 4.6.3
- aux-optimize.php +42 -42
- bulk.php +19 -28
- changelog.txt +7 -0
- classes/class-ewwwio-background-process.php +5 -3
- classes/class-exactdn.php +27 -14
- common.php +13 -2
- ewww-image-optimizer.php +1 -1
- readme.txt +8 -1
- vendor/wp-async-request.php +3 -1
aux-optimize.php
CHANGED
@@ -313,6 +313,23 @@ function ewww_image_optimizer_aux_images_table_count_pending_media() {
|
|
313 |
return $count;
|
314 |
}
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
/**
|
317 |
* Remove all un-optimized images from the ewwwio_images table.
|
318 |
*
|
@@ -440,12 +457,17 @@ function ewww_image_optimizer_insert_unscanned( $ids, $gallery = 'media' ) {
|
|
440 |
*
|
441 |
* @since 4.6.0
|
442 |
*
|
443 |
-
* @param int $
|
444 |
* @param string $gallery The type of attachment to update. Defaults to media library.
|
445 |
* @global object $wpdb
|
446 |
*/
|
447 |
-
function
|
|
|
|
|
|
|
448 |
global $wpdb;
|
|
|
|
|
449 |
$wpdb->update(
|
450 |
$wpdb->ewwwio_queue,
|
451 |
array(
|
@@ -458,6 +480,10 @@ function ewww_image_optimizer_update_scanned_image( $id, $gallery = 'media' ) {
|
|
458 |
array( '%d' ),
|
459 |
array( '%s', '%d' )
|
460 |
);
|
|
|
|
|
|
|
|
|
461 |
}
|
462 |
|
463 |
/**
|
@@ -465,12 +491,17 @@ function ewww_image_optimizer_update_scanned_image( $id, $gallery = 'media' ) {
|
|
465 |
*
|
466 |
* @since 4.6.0
|
467 |
*
|
468 |
-
* @param int $
|
469 |
* @param string $gallery The type of attachment to remove. Defaults to media library.
|
470 |
* @global object $wpdb
|
471 |
*/
|
472 |
-
function
|
|
|
|
|
|
|
473 |
global $wpdb;
|
|
|
|
|
474 |
$wpdb->delete(
|
475 |
$wpdb->ewwwio_queue,
|
476 |
array(
|
@@ -479,6 +510,10 @@ function ewww_image_optimizer_delete_queued_image( $id, $gallery = 'media' ) {
|
|
479 |
),
|
480 |
array( '%s', '%d' )
|
481 |
);
|
|
|
|
|
|
|
|
|
482 |
}
|
483 |
|
484 |
/**
|
@@ -560,11 +595,7 @@ function ewww_image_optimizer_image_scan( $dir, $started = 0 ) {
|
|
560 |
continue;
|
561 |
}
|
562 |
if ( $started && ! empty( $_REQUEST['ewww_scan'] ) && 0 === $file_counter % 100 && microtime( true ) - $started > apply_filters( 'ewww_image_optimizer_timeout', 15 ) ) {
|
563 |
-
|
564 |
-
array_walk( $reset_images, 'intval' );
|
565 |
-
$reset_images_sql = '(' . implode( ',', $reset_images ) . ')';
|
566 |
-
$wpdb->query( "UPDATE $wpdb->ewwwio_images SET pending = 1 WHERE id IN $reset_images_sql" ); // phpcs:ignore WordPress.DB.PreparedSQL
|
567 |
-
}
|
568 |
if ( ! empty( $images ) ) {
|
569 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
570 |
}
|
@@ -592,11 +623,7 @@ function ewww_image_optimizer_image_scan( $dir, $started = 0 ) {
|
|
592 |
)
|
593 |
);
|
594 |
}
|
595 |
-
|
596 |
-
array_walk( $reset_images, 'intval' );
|
597 |
-
$reset_images_sql = '(' . implode( ',', $reset_images ) . ')';
|
598 |
-
$wpdb->query( "UPDATE $wpdb->ewwwio_images SET pending = 1 WHERE id IN $reset_images_sql" ); // phpcs:ignore WordPress.DB.PreparedSQL
|
599 |
-
}
|
600 |
if ( ! empty( $images ) ) {
|
601 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
602 |
}
|
@@ -694,11 +721,7 @@ function ewww_image_optimizer_image_scan( $dir, $started = 0 ) {
|
|
694 |
if ( ! empty( $images ) ) {
|
695 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
696 |
}
|
697 |
-
|
698 |
-
array_walk( $reset_images, 'intval' );
|
699 |
-
$reset_images_sql = '(' . implode( ',', $reset_images ) . ')';
|
700 |
-
$wpdb->query( "UPDATE $wpdb->ewwwio_images SET pending = 1 WHERE id IN $reset_images_sql" ); // phpcs:ignore WordPress.DB.PreparedSQL
|
701 |
-
}
|
702 |
delete_transient( 'ewww_image_optimizer_aux_iterator' );
|
703 |
$end = microtime( true ) - $start;
|
704 |
ewwwio_debug_message( "query time for $file_counter files (seconds): $end" );
|
@@ -952,27 +975,4 @@ function ewww_image_optimizer_aux_images_cleanup( $auto = false ) {
|
|
952 |
add_action( 'wp_ajax_bulk_aux_images_table', 'ewww_image_optimizer_aux_images_table' );
|
953 |
add_action( 'wp_ajax_bulk_aux_images_table_count', 'ewww_image_optimizer_aux_images_table_count' );
|
954 |
add_action( 'wp_ajax_bulk_aux_images_remove', 'ewww_image_optimizer_aux_images_remove' );
|
955 |
-
|
956 |
-
/**
|
957 |
-
* Set a batch of images to pending.
|
958 |
-
*
|
959 |
-
* @global object $wpdb
|
960 |
-
* @global object $ewwwdb A clone of $wpdb unless it is lacking utf8 connectivity.
|
961 |
-
*
|
962 |
-
* @param array $reset_images A list of images to reset in the ewwwio_images table.
|
963 |
-
*/
|
964 |
-
function ewww_image_optimizer_reset_images( $reset_images ) {
|
965 |
-
if ( ! ewww_image_optimizer_iterable( $reset_images ) ) {
|
966 |
-
return;
|
967 |
-
}
|
968 |
-
array_walk( $reset_images, 'intval' );
|
969 |
-
global $wpdb;
|
970 |
-
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
971 |
-
ewww_image_optimizer_db_init();
|
972 |
-
global $ewwwdb;
|
973 |
-
} else {
|
974 |
-
$ewwwdb = $wpdb;
|
975 |
-
}
|
976 |
-
$ewwwdb->query( "UPDATE $ewwwdb->ewwwio_images SET pending = 1, updated = updated WHERE id IN (" . implode( ',', $reset_images ) . ')' );
|
977 |
-
}
|
978 |
?>
|
313 |
return $count;
|
314 |
}
|
315 |
|
316 |
+
/**
|
317 |
+
* Set a batch of images to pending.
|
318 |
+
*
|
319 |
+
* @global object $wpdb
|
320 |
+
*
|
321 |
+
* @param array $reset_images A list of images to reset in the ewwwio_images table.
|
322 |
+
*/
|
323 |
+
function ewww_image_optimizer_reset_images( $reset_images ) {
|
324 |
+
if ( ! ewww_image_optimizer_iterable( $reset_images ) ) {
|
325 |
+
return;
|
326 |
+
}
|
327 |
+
array_walk( $reset_images, 'intval' );
|
328 |
+
global $wpdb;
|
329 |
+
$reset_images_sql = '(' . implode( ',', $reset_images ) . ')';
|
330 |
+
$wpdb->query( "UPDATE $wpdb->ewwwio_images SET pending = 1, updated = updated WHERE id IN $reset_images_sql" ); // phpcs:ignore WordPress.DB.PreparedSQL
|
331 |
+
}
|
332 |
+
|
333 |
/**
|
334 |
* Remove all un-optimized images from the ewwwio_images table.
|
335 |
*
|
457 |
*
|
458 |
* @since 4.6.0
|
459 |
*
|
460 |
+
* @param int $ids The attachment IDs to update.
|
461 |
* @param string $gallery The type of attachment to update. Defaults to media library.
|
462 |
* @global object $wpdb
|
463 |
*/
|
464 |
+
function ewww_image_optimizer_update_scanned_images( $ids, $gallery = 'media' ) {
|
465 |
+
if ( ! ewww_image_optimizer_iterable( $ids ) ) {
|
466 |
+
return;
|
467 |
+
}
|
468 |
global $wpdb;
|
469 |
+
|
470 |
+
/*
|
471 |
$wpdb->update(
|
472 |
$wpdb->ewwwio_queue,
|
473 |
array(
|
480 |
array( '%d' ),
|
481 |
array( '%s', '%d' )
|
482 |
);
|
483 |
+
*/
|
484 |
+
array_walk( $ids, 'intval' );
|
485 |
+
$ids_sql = '(' . implode( ',', $ids ) . ')';
|
486 |
+
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->ewwwio_queue SET scanned = 1 WHERE gallery = %s AND attachment_id IN $ids_sql", $gallery ) ); // phpcs:ignore WordPress.DB.PreparedSQL
|
487 |
}
|
488 |
|
489 |
/**
|
491 |
*
|
492 |
* @since 4.6.0
|
493 |
*
|
494 |
+
* @param int $ids The attachment IDs to remove.
|
495 |
* @param string $gallery The type of attachment to remove. Defaults to media library.
|
496 |
* @global object $wpdb
|
497 |
*/
|
498 |
+
function ewww_image_optimizer_delete_queued_images( $ids, $gallery = 'media' ) {
|
499 |
+
if ( ! ewww_image_optimizer_iterable( $ids ) ) {
|
500 |
+
return;
|
501 |
+
}
|
502 |
global $wpdb;
|
503 |
+
|
504 |
+
/*
|
505 |
$wpdb->delete(
|
506 |
$wpdb->ewwwio_queue,
|
507 |
array(
|
510 |
),
|
511 |
array( '%s', '%d' )
|
512 |
);
|
513 |
+
*/
|
514 |
+
array_walk( $ids, 'intval' );
|
515 |
+
$ids_sql = '(' . implode( ',', $ids ) . ')';
|
516 |
+
$wpdb->query( $wpdb->prepare( "DELETE from $wpdb->ewwwio_queue WHERE gallery = %s AND attachment_id IN $ids_sql", $gallery ) ); // phpcs:ignore WordPress.DB.PreparedSQL
|
517 |
}
|
518 |
|
519 |
/**
|
595 |
continue;
|
596 |
}
|
597 |
if ( $started && ! empty( $_REQUEST['ewww_scan'] ) && 0 === $file_counter % 100 && microtime( true ) - $started > apply_filters( 'ewww_image_optimizer_timeout', 15 ) ) {
|
598 |
+
ewww_image_optimizer_reset_images( $reset_images );
|
|
|
|
|
|
|
|
|
599 |
if ( ! empty( $images ) ) {
|
600 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
601 |
}
|
623 |
)
|
624 |
);
|
625 |
}
|
626 |
+
ewww_image_optimizer_reset_images( $reset_images );
|
|
|
|
|
|
|
|
|
627 |
if ( ! empty( $images ) ) {
|
628 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
629 |
}
|
721 |
if ( ! empty( $images ) ) {
|
722 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, array( '%s', '%d', '%d' ) );
|
723 |
}
|
724 |
+
ewww_image_optimizer_reset_images( $reset_images );
|
|
|
|
|
|
|
|
|
725 |
delete_transient( 'ewww_image_optimizer_aux_iterator' );
|
726 |
$end = microtime( true ) - $start;
|
727 |
ewwwio_debug_message( "query time for $file_counter files (seconds): $end" );
|
975 |
add_action( 'wp_ajax_bulk_aux_images_table', 'ewww_image_optimizer_aux_images_table' );
|
976 |
add_action( 'wp_ajax_bulk_aux_images_table_count', 'ewww_image_optimizer_aux_images_table_count' );
|
977 |
add_action( 'wp_ajax_bulk_aux_images_remove', 'ewww_image_optimizer_aux_images_remove' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
978 |
?>
|
bulk.php
CHANGED
@@ -483,6 +483,10 @@ function ewww_image_optimizer_bulk_script( $hook ) {
|
|
483 |
} else {
|
484 |
$attachment_count = ewww_image_optimizer_count_unscanned_attachments();
|
485 |
}
|
|
|
|
|
|
|
|
|
486 |
wp_enqueue_script( 'ewwwbulkscript', plugins_url( '/includes/eio.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider', 'jquery-ui-progressbar', 'postbox', 'dashboard' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
487 |
// Number of images in the ewwwio_table (previously optimized images).
|
488 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
@@ -680,7 +684,8 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
680 |
$ewwwdb = $wpdb;
|
681 |
}
|
682 |
global $optimized_list;
|
683 |
-
|
|
|
684 |
$tiny_notice = '';
|
685 |
$image_count = 0;
|
686 |
$attachments_processed = 0;
|
@@ -815,7 +820,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
815 |
$remote_file = false;
|
816 |
if ( in_array( $selected_id, $bad_attachments ) ) { // a known broken attachment, which would mean we already tried this once before...
|
817 |
ewwwio_debug_message( "skipping bad attachment $selected_id" );
|
818 |
-
|
819 |
continue;
|
820 |
}
|
821 |
if ( ! empty( $attachment_meta[ $selected_id ]['tinypng'] ) && empty( $_REQUEST['ewww_force'] ) ) {
|
@@ -823,7 +828,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
823 |
if ( ! $tiny_notice ) {
|
824 |
$tiny_notice = esc_html__( 'Images compressed by TinyJPG and TinyPNG have been skipped, refresh and use the Force Re-optimize option to override.', 'ewww-image-optimizer' );
|
825 |
}
|
826 |
-
|
827 |
continue;
|
828 |
}
|
829 |
if ( empty( $attachment_meta[ $selected_id ]['meta'] ) ) {
|
@@ -867,7 +872,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
867 |
}
|
868 |
|
869 |
if ( ! in_array( $mime, $enabled_types ) ) {
|
870 |
-
|
871 |
continue;
|
872 |
}
|
873 |
ewwwio_debug_message( "id: $selected_id and type: $mime" );
|
@@ -891,13 +896,13 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
891 |
ewwwio_debug_message( "remote file possible: $file_path" );
|
892 |
if ( ! $file_path ) {
|
893 |
ewwwio_debug_message( 'no file found on remote storage, bailing' );
|
894 |
-
|
895 |
continue;
|
896 |
}
|
897 |
$remote_file = true;
|
898 |
} elseif ( ! $file_path ) {
|
899 |
ewwwio_debug_message( "no file path for $selected_id" );
|
900 |
-
|
901 |
continue;
|
902 |
}
|
903 |
ewww_image_optimizer_debug_log();
|
@@ -1176,10 +1181,9 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1176 |
if ( $pending ) {
|
1177 |
ewwwio_debug_message( "$selected_id added to queue" );
|
1178 |
ewww_image_optimizer_debug_log();
|
1179 |
-
|
1180 |
-
ewww_image_optimizer_update_scanned_image( $selected_id );
|
1181 |
} else {
|
1182 |
-
|
1183 |
}
|
1184 |
$attachment_images = array();
|
1185 |
ewwwio_debug_message( 'checking for bad attachment' );
|
@@ -1197,21 +1201,11 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1197 |
ewwwio_debug_message( 'finished foreach of attachment_ids' );
|
1198 |
ewww_image_optimizer_debug_log();
|
1199 |
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
$
|
1204 |
-
|
1205 |
-
ewwwio_debug_message( 'storing queued attachments in bulk_attachments' );
|
1206 |
-
ewww_image_optimizer_debug_log();
|
1207 |
-
update_option( 'ewww_image_optimizer_bulk_attachments', $queued_ids, false );
|
1208 |
-
} else {
|
1209 |
-
ewwwio_debug_message( 'storing queued attachments in bulk_attachments, merged with existing' );
|
1210 |
-
ewww_image_optimizer_debug_log();
|
1211 |
-
update_option( 'ewww_image_optimizer_bulk_attachments', array_merge( $attachments_queued, $queued_ids ), false );
|
1212 |
-
}
|
1213 |
-
$queued_ids = array();
|
1214 |
-
*/
|
1215 |
ewwwio_debug_message( 'finished a loop in the while, going back for more possibly' );
|
1216 |
$attachment_ids = ewww_image_optimizer_get_unscanned_attachments( 'media', $max_query );
|
1217 |
ewww_image_optimizer_debug_log();
|
@@ -1221,9 +1215,6 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1221 |
if ( ! empty( $images ) ) {
|
1222 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, $field_formats );
|
1223 |
}
|
1224 |
-
if ( ! empty( $reset_images ) ) {
|
1225 |
-
/* $ewwwdb->query( "UPDATE $ewwwdb->ewwwio_images SET pending = 1, updated = updated WHERE id IN (" . implode( ',', $reset_images ) . ')' ); */
|
1226 |
-
}
|
1227 |
ewww_image_optimizer_reset_images( $reset_images );
|
1228 |
if ( 250 > $attachments_processed ) { // in-memory table is too slow.
|
1229 |
ewwwio_debug_message( 'using in-memory table is too slow, switching to plan b' );
|
@@ -1700,7 +1691,7 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1700 |
}
|
1701 |
// When an image (attachment) is done, pull the next attachment ID off the stack.
|
1702 |
if ( ( 'full' == $next_image->resize || empty( $next_image->resize ) ) && ! empty( $attachment ) && $attachment != $next_image->attachment_id ) {
|
1703 |
-
|
1704 |
$attachment = (int) array_shift( $attachments ); // Pull the first image off the stack.
|
1705 |
if ( ! empty( $attachments ) && is_array( $attachments ) ) {
|
1706 |
$attachment = (int) $attachments[0]; // Then grab the next one (if any are left).
|
483 |
} else {
|
484 |
$attachment_count = ewww_image_optimizer_count_unscanned_attachments();
|
485 |
}
|
486 |
+
if ( empty( $attachment_count ) && ! ewww_image_optimizer_count_attachments() ) {
|
487 |
+
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
488 |
+
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
489 |
+
}
|
490 |
wp_enqueue_script( 'ewwwbulkscript', plugins_url( '/includes/eio.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider', 'jquery-ui-progressbar', 'postbox', 'dashboard' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
491 |
// Number of images in the ewwwio_table (previously optimized images).
|
492 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
684 |
$ewwwdb = $wpdb;
|
685 |
}
|
686 |
global $optimized_list;
|
687 |
+
$queued_ids = array();
|
688 |
+
$skipped_ids = array();
|
689 |
$tiny_notice = '';
|
690 |
$image_count = 0;
|
691 |
$attachments_processed = 0;
|
820 |
$remote_file = false;
|
821 |
if ( in_array( $selected_id, $bad_attachments ) ) { // a known broken attachment, which would mean we already tried this once before...
|
822 |
ewwwio_debug_message( "skipping bad attachment $selected_id" );
|
823 |
+
$skipped_ids[] = $selected_id;
|
824 |
continue;
|
825 |
}
|
826 |
if ( ! empty( $attachment_meta[ $selected_id ]['tinypng'] ) && empty( $_REQUEST['ewww_force'] ) ) {
|
828 |
if ( ! $tiny_notice ) {
|
829 |
$tiny_notice = esc_html__( 'Images compressed by TinyJPG and TinyPNG have been skipped, refresh and use the Force Re-optimize option to override.', 'ewww-image-optimizer' );
|
830 |
}
|
831 |
+
$skipped_ids[] = $selected_id;
|
832 |
continue;
|
833 |
}
|
834 |
if ( empty( $attachment_meta[ $selected_id ]['meta'] ) ) {
|
872 |
}
|
873 |
|
874 |
if ( ! in_array( $mime, $enabled_types ) ) {
|
875 |
+
$skipped_ids[] = $selected_id;
|
876 |
continue;
|
877 |
}
|
878 |
ewwwio_debug_message( "id: $selected_id and type: $mime" );
|
896 |
ewwwio_debug_message( "remote file possible: $file_path" );
|
897 |
if ( ! $file_path ) {
|
898 |
ewwwio_debug_message( 'no file found on remote storage, bailing' );
|
899 |
+
$skipped_ids[] = $selected_id;
|
900 |
continue;
|
901 |
}
|
902 |
$remote_file = true;
|
903 |
} elseif ( ! $file_path ) {
|
904 |
ewwwio_debug_message( "no file path for $selected_id" );
|
905 |
+
$skipped_ids[] = $selected_id;
|
906 |
continue;
|
907 |
}
|
908 |
ewww_image_optimizer_debug_log();
|
1181 |
if ( $pending ) {
|
1182 |
ewwwio_debug_message( "$selected_id added to queue" );
|
1183 |
ewww_image_optimizer_debug_log();
|
1184 |
+
$queued_ids[] = $selected_id;
|
|
|
1185 |
} else {
|
1186 |
+
$skipped_ids[] = $selected_id;
|
1187 |
}
|
1188 |
$attachment_images = array();
|
1189 |
ewwwio_debug_message( 'checking for bad attachment' );
|
1201 |
ewwwio_debug_message( 'finished foreach of attachment_ids' );
|
1202 |
ewww_image_optimizer_debug_log();
|
1203 |
|
1204 |
+
ewww_image_optimizer_update_scanned_images( $queued_ids );
|
1205 |
+
ewww_image_optimizer_delete_queued_images( $skipped_ids );
|
1206 |
+
$queued_ids = array();
|
1207 |
+
$skipped_ids = array();
|
1208 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1209 |
ewwwio_debug_message( 'finished a loop in the while, going back for more possibly' );
|
1210 |
$attachment_ids = ewww_image_optimizer_get_unscanned_attachments( 'media', $max_query );
|
1211 |
ewww_image_optimizer_debug_log();
|
1215 |
if ( ! empty( $images ) ) {
|
1216 |
ewww_image_optimizer_mass_insert( $wpdb->ewwwio_images, $images, $field_formats );
|
1217 |
}
|
|
|
|
|
|
|
1218 |
ewww_image_optimizer_reset_images( $reset_images );
|
1219 |
if ( 250 > $attachments_processed ) { // in-memory table is too slow.
|
1220 |
ewwwio_debug_message( 'using in-memory table is too slow, switching to plan b' );
|
1691 |
}
|
1692 |
// When an image (attachment) is done, pull the next attachment ID off the stack.
|
1693 |
if ( ( 'full' == $next_image->resize || empty( $next_image->resize ) ) && ! empty( $attachment ) && $attachment != $next_image->attachment_id ) {
|
1694 |
+
ewww_image_optimizer_delete_queued_images( array( $attachment ) );
|
1695 |
$attachment = (int) array_shift( $attachments ); // Pull the first image off the stack.
|
1696 |
if ( ! empty( $attachments ) && is_array( $attachments ) ) {
|
1697 |
$attachment = (int) $attachments[0]; // Then grab the next one (if any are left).
|
changelog.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 4.6.2 =
|
2 |
* changed: API key may be defined as EWWW_IMAGE_OPTIMIZER_CLOUD_KEY
|
3 |
* fixed: if img tag is missing dimensions, ExactDN sometimes loads original rather than existing thumbnail
|
1 |
+
= 4.6.3 =
|
2 |
+
* changed: folders to ignore setting applies to resizing also
|
3 |
+
* fixed: lazy load placeholders have inconsistent URLs with ExactDN
|
4 |
+
* fixed: bulk resume indicator gets stuck
|
5 |
+
* fixed: bulk scanning queue gets out of sync and skips images
|
6 |
+
* fixed: async processing does not handle memory limit specified in G (gigabytes)
|
7 |
+
|
8 |
= 4.6.2 =
|
9 |
* changed: API key may be defined as EWWW_IMAGE_OPTIMIZER_CLOUD_KEY
|
10 |
* fixed: if img tag is missing dimensions, ExactDN sometimes loads original rather than existing thumbnail
|
classes/class-ewwwio-background-process.php
CHANGED
@@ -436,19 +436,21 @@ if ( ! class_exists( 'EWWWIO_Background_Process' ) ) {
|
|
436 |
* @return int
|
437 |
*/
|
438 |
protected function get_memory_limit() {
|
|
|
|
|
|
|
439 |
if ( function_exists( 'ini_get' ) ) {
|
440 |
$memory_limit = ini_get( 'memory_limit' );
|
441 |
} else {
|
442 |
// Sensible default.
|
443 |
$memory_limit = '128M';
|
444 |
}
|
445 |
-
|
446 |
if ( ! $memory_limit || -1 === intval( $memory_limit ) ) {
|
447 |
// Unlimited, set to 32GB.
|
448 |
-
$memory_limit = '
|
449 |
}
|
450 |
|
451 |
-
return
|
452 |
}
|
453 |
|
454 |
/**
|
436 |
* @return int
|
437 |
*/
|
438 |
protected function get_memory_limit() {
|
439 |
+
if ( ! function_exists( 'wp_convert_hr_to_bytes' ) ) {
|
440 |
+
return 128 * MB_IN_BYTES;
|
441 |
+
}
|
442 |
if ( function_exists( 'ini_get' ) ) {
|
443 |
$memory_limit = ini_get( 'memory_limit' );
|
444 |
} else {
|
445 |
// Sensible default.
|
446 |
$memory_limit = '128M';
|
447 |
}
|
|
|
448 |
if ( ! $memory_limit || -1 === intval( $memory_limit ) ) {
|
449 |
// Unlimited, set to 32GB.
|
450 |
+
$memory_limit = '32G';
|
451 |
}
|
452 |
|
453 |
+
return wp_convert_hr_to_bytes( $memory_limit );
|
454 |
}
|
455 |
|
456 |
/**
|
classes/class-exactdn.php
CHANGED
@@ -1046,7 +1046,18 @@ class ExactDN extends EWWWIO_Page_Parser {
|
|
1046 |
}
|
1047 |
}
|
1048 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1049 |
} // End if().
|
|
|
1050 |
// At this point, we discard the original src in favor of the ExactDN url.
|
1051 |
if ( ! empty( $exactdn_url ) ) {
|
1052 |
$src = $exactdn_url;
|
@@ -2328,15 +2339,6 @@ class ExactDN extends EWWWIO_Page_Parser {
|
|
2328 |
*/
|
2329 |
$image_url = apply_filters( 'exactdn_pre_image_url', $image_url, $args, $scheme );
|
2330 |
|
2331 |
-
/**
|
2332 |
-
* Filter the ExactDN image parameters before they are applied to an image.
|
2333 |
-
*
|
2334 |
-
* @param array|string $args Array of ExactDN arguments.
|
2335 |
-
* @param string $image_url Image URL.
|
2336 |
-
* @param string|null $scheme Image scheme. Default to null.
|
2337 |
-
*/
|
2338 |
-
$args = apply_filters( 'exactdn_pre_args', $args, $image_url, $scheme );
|
2339 |
-
|
2340 |
if ( empty( $image_url ) ) {
|
2341 |
return $image_url;
|
2342 |
}
|
@@ -2349,6 +2351,22 @@ class ExactDN extends EWWWIO_Page_Parser {
|
|
2349 |
return $image_url;
|
2350 |
}
|
2351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2352 |
if ( is_array( $args ) ) {
|
2353 |
// Convert values that are arrays into strings.
|
2354 |
foreach ( $args as $arg => $value ) {
|
@@ -2419,11 +2437,6 @@ class ExactDN extends EWWWIO_Page_Parser {
|
|
2419 |
}
|
2420 |
ewwwio_debug_message( "exactdn url with args: $exactdn_url" );
|
2421 |
|
2422 |
-
if ( isset( $image_url_parts['scheme'] ) && 'https' == $image_url_parts['scheme'] ) {
|
2423 |
-
$exactdn_url = add_query_arg( 'ssl', 1, $exactdn_url );
|
2424 |
-
$scheme = 'https';
|
2425 |
-
}
|
2426 |
-
|
2427 |
return $this->url_scheme( $exactdn_url, $scheme );
|
2428 |
}
|
2429 |
|
1046 |
}
|
1047 |
}
|
1048 |
}
|
1049 |
+
} elseif ( $lazy && ! empty( $placeholder_src ) && $this->validate_image_url( $placeholder_src ) ) {
|
1050 |
+
$new_tag = $tag;
|
1051 |
+
// If Lazy Load is in use, pass placeholder image through ExactDN.
|
1052 |
+
$placeholder_src = $this->generate_url( $placeholder_src );
|
1053 |
+
if ( $placeholder_src != $placeholder_src_orig ) {
|
1054 |
+
$new_tag = str_replace( $placeholder_src_orig, str_replace( '&', '&', esc_url( $placeholder_src ) ), $new_tag );
|
1055 |
+
// Replace original tag with modified version.
|
1056 |
+
$content = str_replace( $tag, $new_tag, $content );
|
1057 |
+
}
|
1058 |
+
unset( $placeholder_src );
|
1059 |
} // End if().
|
1060 |
+
|
1061 |
// At this point, we discard the original src in favor of the ExactDN url.
|
1062 |
if ( ! empty( $exactdn_url ) ) {
|
1063 |
$src = $exactdn_url;
|
2339 |
*/
|
2340 |
$image_url = apply_filters( 'exactdn_pre_image_url', $image_url, $args, $scheme );
|
2341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2342 |
if ( empty( $image_url ) ) {
|
2343 |
return $image_url;
|
2344 |
}
|
2351 |
return $image_url;
|
2352 |
}
|
2353 |
|
2354 |
+
if ( isset( $image_url_parts['scheme'] ) && 'https' == $image_url_parts['scheme'] ) {
|
2355 |
+
if ( is_array( $args ) ) {
|
2356 |
+
$args['ssl'] = 1;
|
2357 |
+
}
|
2358 |
+
$scheme = 'https';
|
2359 |
+
}
|
2360 |
+
|
2361 |
+
/**
|
2362 |
+
* Filter the ExactDN image parameters before they are applied to an image.
|
2363 |
+
*
|
2364 |
+
* @param array|string $args Array of ExactDN arguments.
|
2365 |
+
* @param string $image_url Image URL.
|
2366 |
+
* @param string|null $scheme Image scheme. Default to null.
|
2367 |
+
*/
|
2368 |
+
$args = apply_filters( 'exactdn_pre_args', $args, $image_url, $scheme );
|
2369 |
+
|
2370 |
if ( is_array( $args ) ) {
|
2371 |
// Convert values that are arrays into strings.
|
2372 |
foreach ( $args as $arg => $value ) {
|
2437 |
}
|
2438 |
ewwwio_debug_message( "exactdn url with args: $exactdn_url" );
|
2439 |
|
|
|
|
|
|
|
|
|
|
|
2440 |
return $this->url_scheme( $exactdn_url, $scheme );
|
2441 |
}
|
2442 |
|
common.php
CHANGED
@@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
23 |
exit;
|
24 |
}
|
25 |
|
26 |
-
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '
|
27 |
|
28 |
// Initialize a couple globals.
|
29 |
$ewww_debug = '';
|
@@ -4635,6 +4635,15 @@ function ewww_image_optimizer_noresize( $dimensions, $filename ) {
|
|
4635 |
if ( strpos( $filename, 'noresize' ) !== false ) {
|
4636 |
return array( 0, 0 );
|
4637 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4638 |
return $dimensions;
|
4639 |
}
|
4640 |
|
@@ -7938,7 +7947,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7938 |
'cookies' => $_COOKIE,
|
7939 |
'sslverify' => false,
|
7940 |
);
|
7941 |
-
|
|
|
|
|
7942 |
if ( is_wp_error( $async_response ) ) {
|
7943 |
$error_message = $async_response->get_error_message();
|
7944 |
ewwwio_debug_message( "async test failed: $error_message" );
|
23 |
exit;
|
24 |
}
|
25 |
|
26 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '463.0' );
|
27 |
|
28 |
// Initialize a couple globals.
|
29 |
$ewww_debug = '';
|
4635 |
if ( strpos( $filename, 'noresize' ) !== false ) {
|
4636 |
return array( 0, 0 );
|
4637 |
}
|
4638 |
+
$ignore_folders = ewww_image_optimizer_get_option( 'ewww_image_optimizer_exclude_paths' );
|
4639 |
+
if ( ! ewww_image_optimizer_iterable( $ignore_folders ) ) {
|
4640 |
+
return $dimensions;
|
4641 |
+
}
|
4642 |
+
foreach ( $ignore_folders as $ignore_folder ) {
|
4643 |
+
if ( strpos( $filename, $ignore_folder ) !== false ) {
|
4644 |
+
return array( 0, 0 );
|
4645 |
+
}
|
4646 |
+
}
|
4647 |
return $dimensions;
|
4648 |
}
|
4649 |
|
7947 |
'cookies' => $_COOKIE,
|
7948 |
'sslverify' => false,
|
7949 |
);
|
7950 |
+
// Don't lock up other requests while processing.
|
7951 |
+
session_write_close();
|
7952 |
+
$async_response = wp_remote_post( esc_url_raw( $admin_ajax_url ), $async_post_args );
|
7953 |
if ( is_wp_error( $async_response ) ) {
|
7954 |
$error_message = $async_response->get_error_message();
|
7955 |
ewwwio_debug_message( "async test failed: $error_message" );
|
ewww-image-optimizer.php
CHANGED
@@ -14,7 +14,7 @@ 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 |
Text Domain: ewww-image-optimizer
|
17 |
-
Version: 4.6.
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
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 |
Text Domain: ewww-image-optimizer
|
17 |
+
Version: 4.6.3
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: image, compress, resize, optimize, optimization, lossless, lossy, seo, web
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 4.6.
|
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.
|
@@ -174,6 +174,13 @@ http://developer.yahoo.com/performance/rules.html#opt_images
|
|
174 |
* Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement
|
175 |
* 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/
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
= 4.6.2 =
|
178 |
* changed: API key may be defined as EWWW_IMAGE_OPTIMIZER_CLOUD_KEY
|
179 |
* fixed: if img tag is missing dimensions, ExactDN sometimes loads original rather than existing thumbnail
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 4.6.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.
|
174 |
* Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement
|
175 |
* 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/
|
176 |
|
177 |
+
= 4.6.3 =
|
178 |
+
* changed: folders to ignore setting applies to resizing also
|
179 |
+
* fixed: lazy load placeholders have inconsistent URLs with ExactDN
|
180 |
+
* fixed: bulk resume indicator gets stuck
|
181 |
+
* fixed: bulk scanning queue gets out of sync and skips images
|
182 |
+
* fixed: async processing does not handle memory limit specified in G (gigabytes)
|
183 |
+
|
184 |
= 4.6.2 =
|
185 |
* changed: API key may be defined as EWWW_IMAGE_OPTIMIZER_CLOUD_KEY
|
186 |
* fixed: if img tag is missing dimensions, ExactDN sometimes loads original rather than existing thumbnail
|
vendor/wp-async-request.php
CHANGED
@@ -84,6 +84,8 @@ if ( ! class_exists( 'WP_Async_Request' ) ) {
|
|
84 |
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
85 |
$args = $this->get_post_args();
|
86 |
|
|
|
|
|
87 |
return wp_remote_post( esc_url_raw( $url ), $args );
|
88 |
}
|
89 |
|
@@ -141,7 +143,7 @@ if ( ! class_exists( 'WP_Async_Request' ) ) {
|
|
141 |
* Check for correct nonce and pass to handler.
|
142 |
*/
|
143 |
public function maybe_handle() {
|
144 |
-
// Don't lock up other requests while processing
|
145 |
session_write_close();
|
146 |
|
147 |
check_ajax_referer( $this->identifier, 'nonce' );
|
84 |
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
85 |
$args = $this->get_post_args();
|
86 |
|
87 |
+
// Close up any loose sessions before we open another request.
|
88 |
+
session_write_close();
|
89 |
return wp_remote_post( esc_url_raw( $url ), $args );
|
90 |
}
|
91 |
|
143 |
* Check for correct nonce and pass to handler.
|
144 |
*/
|
145 |
public function maybe_handle() {
|
146 |
+
// Don't lock up other requests while processing.
|
147 |
session_write_close();
|
148 |
|
149 |
check_ajax_referer( $this->identifier, 'nonce' );
|