Skip to content

Commit

Permalink
Fix the variable containing WP_Error to avoid a fatal (ahmedkaludi#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vegner committed Mar 21, 2018
1 parent a1fbaa7 commit 833f56f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions includes/vendor/aq_resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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?)');
}

Expand All @@ -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());
}

}
Expand Down

0 comments on commit 833f56f

Please sign in to comment.