From 833f56ffd039607ee9e20273b50c8078c6b40176 Mon Sep 17 00:00:00 2001 From: Ivan Vegner Date: Wed, 21 Mar 2018 18:05:43 +0300 Subject: [PATCH] Fix the variable containing WP_Error to avoid a fatal (#1908) --- includes/vendor/aq_resizer.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/vendor/aq_resizer.php b/includes/vendor/aq_resizer.php index 1f030bb1a..c1930f8db 100644 --- a/includes/vendor/aq_resizer.php +++ b/includes/vendor/aq_resizer.php @@ -77,23 +77,23 @@ public function process( $url, $width = null, $height = null, $crop = null, $sin $upload_info = wp_upload_dir(); $upload_dir = $upload_info['basedir']; $upload_url = $upload_info['baseurl']; - + $http_prefix = "http://"; $https_prefix = "https://"; $relative_prefix = "//"; // The protocol-relative URL - - /* if the $url scheme differs from $upload_url scheme, make them match + + /* if the $url scheme differs from $upload_url scheme, make them match if the schemes differe, images don't show up. */ if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well $upload_url = str_replace($http_prefix,$https_prefix,$upload_url); } elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well - $upload_url = str_replace($https_prefix,$http_prefix,$upload_url); + $upload_url = str_replace($https_prefix,$http_prefix,$upload_url); } elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url); } - + // Check if $img_url is local. if ( false === strpos( $url, $upload_url ) ) { @@ -149,7 +149,7 @@ public function process( $url, $width = null, $height = null, $crop = null, $sin $editor = wp_get_image_editor( $img_path ); if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) { - throw new Aq_Exception('Unable to get WP_Image_Editor: ' . + throw new Aq_Exception('Unable to get WP_Image_Editor: ' . $editor->get_error_message() . ' (is GD or ImageMagick installed?)'); } @@ -159,7 +159,7 @@ public function process( $url, $width = null, $height = null, $crop = null, $sin $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] ); $img_url = $upload_url . $resized_rel_path; } else { - throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message()); + throw new Aq_Exception('Unable to save resized image file: ' . $resized_file->get_error_message()); } }