Fatal error
-
(I’m aware have spammed these forums with my posts lately. I apologize for that. Just don’t know how else to document things, so the Author might look at these issues at some point.)
When trying various Face Recognition plugins, like My Eyes are Up Here, I get a fatal error:
wp_basename(Object(WP_Error))
during attempt to do image face detection on a given singular image. The error happens becausewp_basename
is unable to handle a WP_Error object that arises from some kind of incompatibility, so we’d need to tweak a bit the logic of the eval code inclass.wppp_dynamic_images.php
to avoid such showstoppers. Namely:eval (" class WPPP_$editor extends $editor { public function make_subsize( \$size_data ) { if ( ! isset( \$size_data['width'] ) && ! isset( \$size_data['height'] ) ) { return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) ); } \$orig_size = \$this->size; if ( ! isset( \$size_data['width'] ) ) { \$size_data['width'] = null; } if ( ! isset( \$size_data['height'] ) ) { \$size_data['height'] = null; } if ( ! isset( \$size_data['crop'] ) ) { \$size_data['crop'] = false; } \$dims = image_resize_dimensions( \$this->size['width'], \$this->size['height'], \$size_data['width'], \$size_data['height'], \$size_data['crop'] ); if ( \$dims ) { list( \$dst_x, \$dst_y, \$src_x, \$src_y, \$dst_w, \$dst_h, \$src_w, \$src_h ) = \$dims; \$this->update_size( \$dst_w, \$dst_h ); list( \$filename, \$extension, \$mime_type ) = \$this->get_output_format( null, null ); #alx359--> /* Handle gracefully fatal error 'wp_basename(Object(WP_Error))' during image face detection, happening during use of face-Recognition plugins like 'My Eyes Are Up Here' and others. Issue tested with both: Compatible & Fast rewrite if ( ! \$filename ) \$filename = \$this->generate_filename( null, null, \$extension ); \$metadata = array( 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', \$filename ) ), */ \$filename = apply_filters( 'image_make_intermediate_size', \$filename ); if ( !is_string(\$filename) ) { \$filename = \$this->generate_filename( null, null, \$extension ); } \$metadata = array( 'file' => wp_basename( \$filename ), #<--alx359 'width' => \$this->size['width'], 'height' => \$this->size['height'], 'mime-type' => \$mime_type, ); \$this->size = \$orig_size; return \$metadata; } else { return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) ); } } } "); } else { eval (" class WPPP_$editor extends $editor { public function multi_resize( \$sizes ) { \$metadata = array(); /*\$orig_size = \$this->size; foreach ( \$sizes as \$size => \$size_data ) { if ( ! isset( \$size_data['width'] ) && ! isset( \$size_data['height'] ) ) { continue; } if ( ! isset( \$size_data['width'] ) ) { \$size_data['width'] = null; } if ( ! isset( \$size_data['height'] ) ) { \$size_data['height'] = null; } if ( ! isset( \$size_data['crop'] ) ) { \$size_data['crop'] = false; } \$dims = image_resize_dimensions( \$this->size['width'], \$this->size['height'], \$size_data['width'], \$size_data['height'], \$size_data['crop'] ); if ( \$dims ) { list( \$dst_x, \$dst_y, \$src_x, \$src_y, \$dst_w, \$dst_h, \$src_w, \$src_h ) = \$dims; \$this->update_size( \$dst_w, \$dst_h ); list( \$filename, \$extension, \$mime_type ) = \$this->get_output_format( null, null ); #alx359--> /* For the sake of consistency with the code change above if ( ! \$filename ) \$filename = \$this->generate_filename( null, null, \$extension ); \$metadata[\$size] = array( 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', \$filename ) ), */ \$filename = apply_filters( 'image_make_intermediate_size', \$filename ); if ( !is_string(\$filename) ) { \$filename = \$this->generate_filename( null, null, \$extension ); } \$metadata[\$size] = array( 'file' => wp_basename( \$filename ), #<--alx359 'width' => \$this->size['width'], 'height' => \$this->size['height'], 'mime-type' => \$mime_type, ); \$this->size = \$orig_size; } }*/ return \$metadata; } } ");
HTH.
- The topic ‘Fatal error’ is closed to new replies.