Version Description
- changed: use core wp_getimagesize() for proper error handling
- fixed: prevent erasing title attributes for admin users when Lazy Load and Resize Detection are enabled
- fixed: creates empty file when image is too large for WebP conversion
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 6.1.5 |
Comparing to | |
See all releases |
Code changes from version 6.1.4 to 6.1.5
- bulk.php +1 -1
- changelog.txt +5 -0
- classes/class-eio-lazy-load.php +1 -1
- classes/class-eio-page-parser.php +1 -1
- classes/class-ewww-image.php +1 -1
- classes/class-ewwwio-gd-editor.php +4 -4
- classes/class-ewwwio-gmagick-editor.php +1 -1
- classes/class-ewwwio-imagick-editor.php +5 -5
- common.php +30 -10
- ewww-image-optimizer.php +1 -1
- includes/resize_detection.js +4 -1
- readme.txt +8 -3
- tests/test-resize.php +4 -4
- unique.php +7 -6
bulk.php
CHANGED
@@ -899,7 +899,7 @@ function ewww_image_optimizer_should_resize( $file, $media = false ) {
|
|
899 |
$maxwidth = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
|
900 |
$maxheight = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' );
|
901 |
}
|
902 |
-
list( $oldwidth, $oldheight ) =
|
903 |
if ( ( $maxwidth && $oldwidth > $maxwidth ) || ( $maxheight && $oldheight > $maxheight ) ) {
|
904 |
ewwwio_debug_message( "$file ($oldwidth x $oldheight) larger than $maxwidth x $maxheight" );
|
905 |
return true;
|
899 |
$maxwidth = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
|
900 |
$maxheight = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' );
|
901 |
}
|
902 |
+
list( $oldwidth, $oldheight ) = wp_getimagesize( $file );
|
903 |
if ( ( $maxwidth && $oldwidth > $maxwidth ) || ( $maxheight && $oldheight > $maxheight ) ) {
|
904 |
ewwwio_debug_message( "$file ($oldwidth x $oldheight) larger than $maxwidth x $maxheight" );
|
905 |
return true;
|
changelog.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 6.1.4 =
|
2 |
* changed: better handling for API quotas
|
3 |
* fixed: picture elements not parsed when using JS WebP with Lazy Load
|
1 |
+
= 6.1.5 =
|
2 |
+
* changed: use core wp_getimagesize() for proper error handling
|
3 |
+
* fixed: prevent erasing title attributes for admin users when Lazy Load and Resize Detection are enabled
|
4 |
+
* fixed: creates empty file when image is too large for WebP conversion
|
5 |
+
|
6 |
= 6.1.4 =
|
7 |
* changed: better handling for API quotas
|
8 |
* fixed: picture elements not parsed when using JS WebP with Lazy Load
|
classes/class-eio-lazy-load.php
CHANGED
@@ -546,8 +546,8 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
546 |
}
|
547 |
$this->debug_message( "current placeholder is $placeholder_src" );
|
548 |
|
|
|
549 |
if ( $srcset ) {
|
550 |
-
$placeholder_src = apply_filters( 'eio_lazy_placeholder', $placeholder_src, $image );
|
551 |
if ( strpos( $placeholder_src, '64,R0lGOD' ) ) {
|
552 |
$this->set_attribute( $image, 'srcset', $placeholder_src, true );
|
553 |
$this->remove_attribute( $image, 'src' );
|
546 |
}
|
547 |
$this->debug_message( "current placeholder is $placeholder_src" );
|
548 |
|
549 |
+
$placeholder_src = apply_filters( 'eio_lazy_placeholder', $placeholder_src, $image );
|
550 |
if ( $srcset ) {
|
|
|
551 |
if ( strpos( $placeholder_src, '64,R0lGOD' ) ) {
|
552 |
$this->set_attribute( $image, 'srcset', $placeholder_src, true );
|
553 |
$this->remove_attribute( $image, 'src' );
|
classes/class-eio-page-parser.php
CHANGED
@@ -242,7 +242,7 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
242 |
$file = $this->url_to_path_exists( $url );
|
243 |
}
|
244 |
if ( $file && $this->is_file( $file ) ) {
|
245 |
-
list( $width, $height ) =
|
246 |
}
|
247 |
}
|
248 |
$width = $width && is_numeric( $width ) ? (int) $width : false;
|
242 |
$file = $this->url_to_path_exists( $url );
|
243 |
}
|
244 |
if ( $file && $this->is_file( $file ) ) {
|
245 |
+
list( $width, $height ) = wp_getimagesize( $file );
|
246 |
}
|
247 |
}
|
248 |
$width = $width && is_numeric( $width ) ? (int) $width : false;
|
classes/class-ewww-image.php
CHANGED
@@ -626,7 +626,7 @@ class EWWW_Image {
|
|
626 |
// Retrieve the data from the PNG.
|
627 |
$input = imagecreatefrompng( $file );
|
628 |
// Retrieve the dimensions of the PNG.
|
629 |
-
list( $width, $height ) =
|
630 |
// Create a new image with those dimensions.
|
631 |
$output = imagecreatetruecolor( $width, $height );
|
632 |
if ( '' === $r ) {
|
626 |
// Retrieve the data from the PNG.
|
627 |
$input = imagecreatefrompng( $file );
|
628 |
// Retrieve the dimensions of the PNG.
|
629 |
+
list( $width, $height ) = wp_getimagesize( $file );
|
630 |
// Create a new image with those dimensions.
|
631 |
$output = imagecreatetruecolor( $width, $height );
|
632 |
if ( '' === $r ) {
|
classes/class-ewwwio-gd-editor.php
CHANGED
@@ -40,7 +40,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
40 |
}
|
41 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
42 |
ewwwio_debug_message( "detected existing file: $filename" );
|
43 |
-
$current_size =
|
44 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
45 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
46 |
return array(
|
@@ -100,7 +100,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
100 |
}
|
101 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
102 |
ewwwio_debug_message( "detected existing file: $filename" );
|
103 |
-
$current_size =
|
104 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
105 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
106 |
return array(
|
@@ -457,7 +457,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
457 |
global $ewww_preempt_editor;
|
458 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) && empty( $ewww_preempt_editor ) ) {
|
459 |
ewwwio_debug_message( "detected existing file: $filename" );
|
460 |
-
$current_size =
|
461 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
462 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
463 |
return array(
|
@@ -518,7 +518,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
518 |
}
|
519 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
520 |
ewwwio_debug_message( "detected existing file: $filename" );
|
521 |
-
$current_size =
|
522 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
523 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
524 |
return array(
|
40 |
}
|
41 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
42 |
ewwwio_debug_message( "detected existing file: $filename" );
|
43 |
+
$current_size = wp_getimagesize( $filename );
|
44 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
45 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
46 |
return array(
|
100 |
}
|
101 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
102 |
ewwwio_debug_message( "detected existing file: $filename" );
|
103 |
+
$current_size = wp_getimagesize( $filename );
|
104 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
105 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
106 |
return array(
|
457 |
global $ewww_preempt_editor;
|
458 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) && empty( $ewww_preempt_editor ) ) {
|
459 |
ewwwio_debug_message( "detected existing file: $filename" );
|
460 |
+
$current_size = wp_getimagesize( $filename );
|
461 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
462 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
463 |
return array(
|
518 |
}
|
519 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
520 |
ewwwio_debug_message( "detected existing file: $filename" );
|
521 |
+
$current_size = wp_getimagesize( $filename );
|
522 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
523 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
524 |
return array(
|
classes/class-ewwwio-gmagick-editor.php
CHANGED
@@ -36,7 +36,7 @@ if ( class_exists( 'WP_Image_Editor_Gmagick' ) ) {
|
|
36 |
}
|
37 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
38 |
ewwwio_debug_message( "detected existing file: $filename" );
|
39 |
-
$current_size =
|
40 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
41 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
42 |
return array(
|
36 |
}
|
37 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
38 |
ewwwio_debug_message( "detected existing file: $filename" );
|
39 |
+
$current_size = wp_getimagesize( $filename );
|
40 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
41 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
42 |
return array(
|
classes/class-ewwwio-imagick-editor.php
CHANGED
@@ -38,7 +38,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
38 |
}
|
39 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
40 |
ewwwio_debug_message( "detected existing file: $filename" );
|
41 |
-
$current_size =
|
42 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
43 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
44 |
return array(
|
@@ -96,7 +96,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
96 |
}
|
97 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
98 |
ewwwio_debug_message( "detected existing file: $filename" );
|
99 |
-
$current_size =
|
100 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
101 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
102 |
return array(
|
@@ -155,7 +155,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
155 |
}
|
156 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
157 |
ewwwio_debug_message( "detected existing file: $filename" );
|
158 |
-
$current_size =
|
159 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
160 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
161 |
return array(
|
@@ -503,7 +503,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
503 |
global $ewww_preempt_editor;
|
504 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) && empty( $ewww_preempt_editor ) ) {
|
505 |
ewwwio_debug_message( "detected existing file: $filename" );
|
506 |
-
$current_size =
|
507 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
508 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
509 |
return array(
|
@@ -564,7 +564,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
564 |
}
|
565 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
566 |
ewwwio_debug_message( "detected existing file: $filename" );
|
567 |
-
$current_size =
|
568 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
569 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
570 |
return array(
|
38 |
}
|
39 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
40 |
ewwwio_debug_message( "detected existing file: $filename" );
|
41 |
+
$current_size = wp_getimagesize( $filename );
|
42 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
43 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
44 |
return array(
|
96 |
}
|
97 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
98 |
ewwwio_debug_message( "detected existing file: $filename" );
|
99 |
+
$current_size = wp_getimagesize( $filename );
|
100 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
101 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
102 |
return array(
|
155 |
}
|
156 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
157 |
ewwwio_debug_message( "detected existing file: $filename" );
|
158 |
+
$current_size = wp_getimagesize( $filename );
|
159 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
160 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
161 |
return array(
|
503 |
global $ewww_preempt_editor;
|
504 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) && empty( $ewww_preempt_editor ) ) {
|
505 |
ewwwio_debug_message( "detected existing file: $filename" );
|
506 |
+
$current_size = wp_getimagesize( $filename );
|
507 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
508 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
509 |
return array(
|
564 |
}
|
565 |
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
566 |
ewwwio_debug_message( "detected existing file: $filename" );
|
567 |
+
$current_size = wp_getimagesize( $filename );
|
568 |
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
569 |
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
570 |
return array(
|
common.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
@@ -483,6 +483,18 @@ if ( ! function_exists( 'boolval' ) ) {
|
|
483 |
return (bool) $value;
|
484 |
}
|
485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
|
487 |
/**
|
488 |
* Wrapper around json_encode to handle non-utf8 characters.
|
@@ -3637,15 +3649,16 @@ function ewwwio_delete_file( $file, $dir = '' ) {
|
|
3637 |
function ewwwio_chmod( $file, $mode ) {
|
3638 |
global $eio_filesystem;
|
3639 |
ewwwio_get_filesystem();
|
|
|
3640 |
$file = realpath( $file );
|
3641 |
$upload_dir = wp_get_upload_dir();
|
3642 |
-
if ( false !== strpos( $file, $upload_dir['basedir'] ) ) {
|
3643 |
return $eio_filesystem->chmod( $file, $mode );
|
3644 |
}
|
3645 |
-
if ( false !== strpos( $file, WP_CONTENT_DIR ) ) {
|
3646 |
return $eio_filesystem->chmod( $file, $mode );
|
3647 |
}
|
3648 |
-
if ( false !== strpos( $file, ABSPATH ) ) {
|
3649 |
return $eio_filesystem->chmod( $file, $mode );
|
3650 |
}
|
3651 |
return false;
|
@@ -3836,7 +3849,7 @@ function ewww_image_optimizer_cloud_restore_from_meta_data( $id, $gallery = 'med
|
|
3836 |
}
|
3837 |
ewww_image_optimizer_cloud_restore_single_image( $image );
|
3838 |
if ( 'media' === $gallery && 'full' === $image['resize'] && ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
|
3839 |
-
list( $width, $height ) =
|
3840 |
if ( (int) $width !== (int) $meta['width'] || (int) $height !== (int) $meta['height'] ) {
|
3841 |
$meta['height'] = $height;
|
3842 |
$meta['width'] = $width;
|
@@ -6275,6 +6288,8 @@ function ewww_image_optimizer_remote_fetch( $id, $meta ) {
|
|
6275 |
} else {
|
6276 |
unlink( $temp_file );
|
6277 |
}
|
|
|
|
|
6278 |
}
|
6279 |
// Resized versions, so we'll grab those too.
|
6280 |
if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
|
@@ -6352,6 +6367,8 @@ function ewww_image_optimizer_remote_fetch( $id, $meta ) {
|
|
6352 |
if ( ! ewwwio_is_file( $filename ) ) {
|
6353 |
ewwwio_debug_message( 'download failed' );
|
6354 |
}
|
|
|
|
|
6355 |
}
|
6356 |
$base_dir = trailingslashit( dirname( $filename ) );
|
6357 |
// Original image detected.
|
@@ -6369,6 +6386,8 @@ function ewww_image_optimizer_remote_fetch( $id, $meta ) {
|
|
6369 |
wp_mkdir_p( $base_dir );
|
6370 |
}
|
6371 |
ewwwio_rename( $temp_file, $resize_path );
|
|
|
|
|
6372 |
}
|
6373 |
}
|
6374 |
}
|
@@ -6919,7 +6938,7 @@ function ewww_image_optimizer_resize_upload( $file ) {
|
|
6919 |
return false;
|
6920 |
}
|
6921 |
// Check file size (dimensions).
|
6922 |
-
list( $oldwidth, $oldheight ) =
|
6923 |
if ( $oldwidth <= $maxwidth && $oldheight <= $maxheight ) {
|
6924 |
ewwwio_debug_message( 'image too small for resizing' );
|
6925 |
/* translators: 1: width in pixels 2: height in pixels */
|
@@ -8581,7 +8600,7 @@ function ewww_image_optimizer_png_alpha( $filename ) {
|
|
8581 |
ewwwio_debug_message( 'transparency found' );
|
8582 |
return true;
|
8583 |
}
|
8584 |
-
list( $width, $height ) =
|
8585 |
ewwwio_debug_message( "image dimensions: $width x $height" );
|
8586 |
ewwwio_debug_message( 'preparing to scan image' );
|
8587 |
for ( $y = 0; $y < $height; $y++ ) {
|
@@ -10580,7 +10599,7 @@ function ewwwio_debug_info() {
|
|
10580 |
ewwwio_debug_message( $webp_paths );
|
10581 |
ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ? 'on' : 'off' ) );
|
10582 |
if ( ewww_image_optimizer_cloud_based_media() ) {
|
10583 |
-
ewwwio_debug_message( '
|
10584 |
}
|
10585 |
ewwwio_debug_message( 'forced gif2webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ? 'on' : 'off' ) );
|
10586 |
ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ? 'yes' : 'no' ) );
|
@@ -12300,7 +12319,8 @@ AddType image/webp .webp</pre>
|
|
12300 |
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span><br>
|
12301 |
<p class='description'>
|
12302 |
<?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?>
|
12303 |
-
<?php esc_html_e( 'Some themes may not display <picture> tags properly
|
|
|
12304 |
</p>
|
12305 |
</td>
|
12306 |
</tr>
|
@@ -12913,7 +12933,7 @@ AddType image/webp .webp</pre>
|
|
12913 |
<p>
|
12914 |
<a class='ewww-docs-root' href='https://docs.ewww.io/'><?php esc_html_e( 'Documentation', 'ewww-image-optimizer' ); ?></a> |
|
12915 |
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'><?php esc_html_e( 'Plugin Support', 'ewww-image-optimizer' ); ?></a> |
|
12916 |
-
<a href='https://feedback.ewww.io/'><?php esc_html_e( 'Submit Feedback', 'ewww-image-optimizer' ); ?></a> |
|
12917 |
<a href='https://ewww.io/status/'><?php esc_html_e( 'Server Status', 'ewww-image-optimizer' ); ?></a>
|
12918 |
</p>
|
12919 |
<p style='float:right;'>
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '615' );
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
483 |
return (bool) $value;
|
484 |
}
|
485 |
}
|
486 |
+
if ( ! function_exists( 'wp_getimagesize' ) ) {
|
487 |
+
/**
|
488 |
+
* Stub for WP prior to 5.7.
|
489 |
+
*
|
490 |
+
* @param string $filename The file path.
|
491 |
+
* @return array|false Array of image information or false on failure.
|
492 |
+
*/
|
493 |
+
function wp_getimagesize( $filename ) {
|
494 |
+
// phpcs:ignore WordPress.PHP.NoSilencedErrors
|
495 |
+
return @getimagesize( $filename );
|
496 |
+
}
|
497 |
+
}
|
498 |
|
499 |
/**
|
500 |
* Wrapper around json_encode to handle non-utf8 characters.
|
3649 |
function ewwwio_chmod( $file, $mode ) {
|
3650 |
global $eio_filesystem;
|
3651 |
ewwwio_get_filesystem();
|
3652 |
+
clearstatcache();
|
3653 |
$file = realpath( $file );
|
3654 |
$upload_dir = wp_get_upload_dir();
|
3655 |
+
if ( false !== strpos( $file, $upload_dir['basedir'] ) && is_writable( $file ) ) {
|
3656 |
return $eio_filesystem->chmod( $file, $mode );
|
3657 |
}
|
3658 |
+
if ( false !== strpos( $file, WP_CONTENT_DIR ) && is_writable( $file ) ) {
|
3659 |
return $eio_filesystem->chmod( $file, $mode );
|
3660 |
}
|
3661 |
+
if ( false !== strpos( $file, ABSPATH ) && is_writable( $file ) ) {
|
3662 |
return $eio_filesystem->chmod( $file, $mode );
|
3663 |
}
|
3664 |
return false;
|
3849 |
}
|
3850 |
ewww_image_optimizer_cloud_restore_single_image( $image );
|
3851 |
if ( 'media' === $gallery && 'full' === $image['resize'] && ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
|
3852 |
+
list( $width, $height ) = wp_getimagesize( $image['path'] );
|
3853 |
if ( (int) $width !== (int) $meta['width'] || (int) $height !== (int) $meta['height'] ) {
|
3854 |
$meta['height'] = $height;
|
3855 |
$meta['width'] = $width;
|
6288 |
} else {
|
6289 |
unlink( $temp_file );
|
6290 |
}
|
6291 |
+
} elseif ( is_wp_error( $temp_file ) ) {
|
6292 |
+
ewwwio_debug_message( 'could not download: ' . $temp_file->get_error_message() );
|
6293 |
}
|
6294 |
// Resized versions, so we'll grab those too.
|
6295 |
if ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
|
6367 |
if ( ! ewwwio_is_file( $filename ) ) {
|
6368 |
ewwwio_debug_message( 'download failed' );
|
6369 |
}
|
6370 |
+
} elseif ( is_wp_error( $temp_file ) ) {
|
6371 |
+
ewwwio_debug_message( 'could not download: ' . $temp_file->get_error_message() );
|
6372 |
}
|
6373 |
$base_dir = trailingslashit( dirname( $filename ) );
|
6374 |
// Original image detected.
|
6386 |
wp_mkdir_p( $base_dir );
|
6387 |
}
|
6388 |
ewwwio_rename( $temp_file, $resize_path );
|
6389 |
+
} elseif ( is_wp_error( $temp_file ) ) {
|
6390 |
+
ewwwio_debug_message( 'could not download: ' . $temp_file->get_error_message() );
|
6391 |
}
|
6392 |
}
|
6393 |
}
|
6938 |
return false;
|
6939 |
}
|
6940 |
// Check file size (dimensions).
|
6941 |
+
list( $oldwidth, $oldheight ) = wp_getimagesize( $file );
|
6942 |
if ( $oldwidth <= $maxwidth && $oldheight <= $maxheight ) {
|
6943 |
ewwwio_debug_message( 'image too small for resizing' );
|
6944 |
/* translators: 1: width in pixels 2: height in pixels */
|
8600 |
ewwwio_debug_message( 'transparency found' );
|
8601 |
return true;
|
8602 |
}
|
8603 |
+
list( $width, $height ) = wp_getimagesize( $filename );
|
8604 |
ewwwio_debug_message( "image dimensions: $width x $height" );
|
8605 |
ewwwio_debug_message( 'preparing to scan image' );
|
8606 |
for ( $y = 0; $y < $height; $y++ ) {
|
10599 |
ewwwio_debug_message( $webp_paths );
|
10600 |
ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ? 'on' : 'off' ) );
|
10601 |
if ( ewww_image_optimizer_cloud_based_media() ) {
|
10602 |
+
ewwwio_debug_message( 'cloud-based media (no local copies), force webp auto-enabled' );
|
10603 |
}
|
10604 |
ewwwio_debug_message( 'forced gif2webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ? 'on' : 'off' ) );
|
10605 |
ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ? 'yes' : 'no' ) );
|
12319 |
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span><br>
|
12320 |
<p class='description'>
|
12321 |
<?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?>
|
12322 |
+
<?php esc_html_e( 'Some themes may not display <picture> tags properly.', 'ewww-image-optimizer' ); ?>
|
12323 |
+
<?php esc_html_e( 'May be combined with JS WebP and Lazy Load for CSS background image support.', 'ewww-image-optimizer' ); ?>
|
12324 |
</p>
|
12325 |
</td>
|
12326 |
</tr>
|
12933 |
<p>
|
12934 |
<a class='ewww-docs-root' href='https://docs.ewww.io/'><?php esc_html_e( 'Documentation', 'ewww-image-optimizer' ); ?></a> |
|
12935 |
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'><?php esc_html_e( 'Plugin Support', 'ewww-image-optimizer' ); ?></a> |
|
12936 |
+
<a href='https://feedback.ewww.io/b/features'><?php esc_html_e( 'Submit Feedback', 'ewww-image-optimizer' ); ?></a> |
|
12937 |
<a href='https://ewww.io/status/'><?php esc_html_e( 'Server Status', 'ewww-image-optimizer' ); ?></a>
|
12938 |
</p>
|
12939 |
<p style='float:right;'>
|
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: 6.1.
|
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: 6.1.5
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
includes/resize_detection.js
CHANGED
@@ -45,6 +45,9 @@ function clearScaledImages() {
|
|
45 |
}
|
46 |
document.addEventListener('lazyloaded', function(e){
|
47 |
e.target.classList.remove('scaled-image');
|
48 |
-
|
|
|
|
|
|
|
49 |
checkImageScale(e.target);
|
50 |
});
|
45 |
}
|
46 |
document.addEventListener('lazyloaded', function(e){
|
47 |
e.target.classList.remove('scaled-image');
|
48 |
+
var current_title = e.target.title;
|
49 |
+
if (0 === current_title.search('Forced to wrong size')) {
|
50 |
+
e.target.title = '';
|
51 |
+
}
|
52 |
checkImageScale(e.target);
|
53 |
});
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
|
|
5 |
Requires at least: 5.4
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 7.1
|
8 |
-
Stable tag: 6.1.
|
9 |
License: GPLv3
|
10 |
|
11 |
Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
|
@@ -37,7 +37,7 @@ With Easy IO, images are automatically compressed, scaled to fit the page and de
|
|
37 |
= Support =
|
38 |
|
39 |
Stuck? Feeling like maybe you DO need that rocket science degree? [We provide free one-on-one email support to everyone](https://ewww.io/contact-us/).
|
40 |
-
Do you have an idea to make EWWW IO even better? [Share it and vote on future features](https://feedback.ewww.io/)!
|
41 |
Found a bug? Report the issue on [GitHub](https://github.com/nosilver4u/ewww-image-optimizer), and we'll get it fixed!
|
42 |
|
43 |
= Bulk Optimize =
|
@@ -129,9 +129,14 @@ That's not a question, but since I made it up, I'll answer it. See this resource
|
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
-
* Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
|
133 |
* If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
|
134 |
|
|
|
|
|
|
|
|
|
|
|
135 |
= 6.1.4 =
|
136 |
* changed: better handling for API quotas
|
137 |
* fixed: picture elements not parsed when using JS WebP with Lazy Load
|
5 |
Requires at least: 5.4
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 7.1
|
8 |
+
Stable tag: 6.1.5
|
9 |
License: GPLv3
|
10 |
|
11 |
Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
|
37 |
= Support =
|
38 |
|
39 |
Stuck? Feeling like maybe you DO need that rocket science degree? [We provide free one-on-one email support to everyone](https://ewww.io/contact-us/).
|
40 |
+
Do you have an idea to make EWWW IO even better? [Share it and vote on future features](https://feedback.ewww.io/b/features)!
|
41 |
Found a bug? Report the issue on [GitHub](https://github.com/nosilver4u/ewww-image-optimizer), and we'll get it fixed!
|
42 |
|
43 |
= Bulk Optimize =
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
+
* Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io/b/features)
|
133 |
* If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
|
134 |
|
135 |
+
= 6.1.5 =
|
136 |
+
* changed: use core wp_getimagesize() for proper error handling
|
137 |
+
* fixed: prevent erasing title attributes for admin users when Lazy Load and Resize Detection are enabled
|
138 |
+
* fixed: creates empty file when image is too large for WebP conversion
|
139 |
+
|
140 |
= 6.1.4 =
|
141 |
* changed: better handling for API quotas
|
142 |
* fixed: picture elements not parsed when using JS WebP with Lazy Load
|
tests/test-resize.php
CHANGED
@@ -67,7 +67,7 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
67 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
68 |
$meta = wp_get_attachment_metadata( $id );
|
69 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
70 |
-
list( $width, $height ) =
|
71 |
$this->assertEquals( 576, $width );
|
72 |
$this->assertEquals( 1024, $height );
|
73 |
}
|
@@ -87,7 +87,7 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
87 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
88 |
$meta = wp_get_attachment_metadata( $id );
|
89 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
90 |
-
list( $width, $height ) =
|
91 |
$this->assertEquals( 1024, $width );
|
92 |
$this->assertEquals( 1024, $height );
|
93 |
}
|
@@ -106,7 +106,7 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
106 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
107 |
$meta = wp_get_attachment_metadata( $id );
|
108 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
109 |
-
list( $width, $height ) =
|
110 |
$this->assertEquals( 576, $width );
|
111 |
$this->assertEquals( 1024, $height );
|
112 |
}
|
@@ -127,7 +127,7 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
127 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
128 |
$meta = wp_get_attachment_metadata( $id );
|
129 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
130 |
-
list( $width, $height ) =
|
131 |
$this->assertEquals( 1024, $width );
|
132 |
$this->assertEquals( 1024, $height );
|
133 |
}
|
67 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
68 |
$meta = wp_get_attachment_metadata( $id );
|
69 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
70 |
+
list( $width, $height ) = wp_getimagesize( $file_path );
|
71 |
$this->assertEquals( 576, $width );
|
72 |
$this->assertEquals( 1024, $height );
|
73 |
}
|
87 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
88 |
$meta = wp_get_attachment_metadata( $id );
|
89 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
90 |
+
list( $width, $height ) = wp_getimagesize( $file_path );
|
91 |
$this->assertEquals( 1024, $width );
|
92 |
$this->assertEquals( 1024, $height );
|
93 |
}
|
106 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
107 |
$meta = wp_get_attachment_metadata( $id );
|
108 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
109 |
+
list( $width, $height ) = wp_getimagesize( $file_path );
|
110 |
$this->assertEquals( 576, $width );
|
111 |
$this->assertEquals( 1024, $height );
|
112 |
}
|
127 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
128 |
$meta = wp_get_attachment_metadata( $id );
|
129 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
130 |
+
list( $width, $height ) = wp_getimagesize( $file_path );
|
131 |
$this->assertEquals( 1024, $width );
|
132 |
$this->assertEquals( 1024, $height );
|
133 |
}
|
unique.php
CHANGED
@@ -1265,10 +1265,7 @@ function ewww_image_optimizer_md5check( $path ) {
|
|
1265 |
}
|
1266 |
|
1267 |
/**
|
1268 |
-
* Check the mimetype of the given file with
|
1269 |
-
*
|
1270 |
-
* Checks WebP files using a direct pattern match, then prefers fileinfo, getimagesize (for images
|
1271 |
-
* only), mime_content_type, and lastly the 'file' utility (only for binaries).
|
1272 |
*
|
1273 |
* @param string $path The absolute path to the file.
|
1274 |
* @param string $case The type of file we are checking. Accepts 'i' for
|
@@ -1756,7 +1753,7 @@ function ewww_image_optimizer_gifsicle_resize( $file, $dst_x, $dst_y, $src_x, $s
|
|
1756 |
ewwwio_debug_message( "width: $dst_w" );
|
1757 |
ewwwio_debug_message( "height: $dst_h" );
|
1758 |
|
1759 |
-
list( $orig_w, $orig_h ) =
|
1760 |
|
1761 |
$outfile = "$file.tmp";
|
1762 |
// Run gifsicle.
|
@@ -2536,7 +2533,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2536 |
// Retrieve the data from the PNG.
|
2537 |
$input = imagecreatefrompng( $file );
|
2538 |
// Retrieve the dimensions of the PNG.
|
2539 |
-
list($width, $height) =
|
2540 |
// Create a new image with those dimensions.
|
2541 |
$output = imagecreatetruecolor( $width, $height );
|
2542 |
if ( '' === $r ) {
|
@@ -2976,6 +2973,10 @@ function ewww_image_optimizer_webp_create( $file, $orig_size, $type, $tool, $rec
|
|
2976 |
ewwwio_debug_message( 'APNG found, WebP not possible' );
|
2977 |
return esc_html__( 'APNG cannot be converted to WebP.', 'ewww-image-optimizer' );
|
2978 |
}
|
|
|
|
|
|
|
|
|
2979 |
if ( empty( $tool ) || 'image/gif' === $type ) {
|
2980 |
ewww_image_optimizer_cloud_optimizer( $file, $type, false, $webpfile, 'image/webp' );
|
2981 |
} else {
|
1265 |
}
|
1266 |
|
1267 |
/**
|
1268 |
+
* Check the mimetype of the given file with magic mime strings/patterns.
|
|
|
|
|
|
|
1269 |
*
|
1270 |
* @param string $path The absolute path to the file.
|
1271 |
* @param string $case The type of file we are checking. Accepts 'i' for
|
1753 |
ewwwio_debug_message( "width: $dst_w" );
|
1754 |
ewwwio_debug_message( "height: $dst_h" );
|
1755 |
|
1756 |
+
list( $orig_w, $orig_h ) = wp_getimagesize( $file );
|
1757 |
|
1758 |
$outfile = "$file.tmp";
|
1759 |
// Run gifsicle.
|
2533 |
// Retrieve the data from the PNG.
|
2534 |
$input = imagecreatefrompng( $file );
|
2535 |
// Retrieve the dimensions of the PNG.
|
2536 |
+
list($width, $height) = wp_getimagesize( $file );
|
2537 |
// Create a new image with those dimensions.
|
2538 |
$output = imagecreatetruecolor( $width, $height );
|
2539 |
if ( '' === $r ) {
|
2973 |
ewwwio_debug_message( 'APNG found, WebP not possible' );
|
2974 |
return esc_html__( 'APNG cannot be converted to WebP.', 'ewww-image-optimizer' );
|
2975 |
}
|
2976 |
+
list( $width, $height ) = wp_getimagesize( $file );
|
2977 |
+
if ( $width > 16383 || $height > 16383 ) {
|
2978 |
+
return esc_html__( 'Image dimensions too large for WebP conversion.', 'ewww-image-optimizer' );
|
2979 |
+
}
|
2980 |
if ( empty( $tool ) || 'image/gif' === $type ) {
|
2981 |
ewww_image_optimizer_cloud_optimizer( $file, $type, false, $webpfile, 'image/webp' );
|
2982 |
} else {
|