Skip to content

Commit

Permalink
Ensure metadata is an array before proceeding. Remove code that isn't…
Browse files Browse the repository at this point in the history
… needed
  • Loading branch information
dkotter committed Feb 1, 2024
1 parent 28381c8 commit e6073d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions includes/Classifai/Features/ImageCropping.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,8 @@ public function attachment_data_meta_box_content() {
* @param int $attachment_id Attachment ID.
*/
public function maybe_crop_image( int $attachment_id ) {
$metadata = wp_get_attachment_metadata( $attachment_id );

if ( clean_input( 'rescan-smart-crop' ) ) {
$result = $this->run( $attachment_id, 'crop', $metadata );
$result = $this->run( $attachment_id, 'crop' );

if ( ! empty( $result ) && ! is_wp_error( $result ) ) {
$meta = $this->save( $result, $attachment_id );
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/Azure/ComputerVision.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ public function rest_endpoint_callback( $attachment_id, string $route_to_call =

$metadata = wp_get_attachment_metadata( $attachment_id );

if ( ! $metadata ) {
if ( ! $metadata || ! is_array( $metadata ) ) {
return new WP_Error( 'invalid', esc_html__( 'No valid metadata found.', 'classifai' ) );
}

Expand Down

0 comments on commit e6073d5

Please sign in to comment.