From a6df9969f4ab5e6db4a4555f487d749feabf06c9 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 7 Mar 2016 14:39:42 -0300 Subject: [PATCH] Fixed image upload --- includes/wc-api-functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/wc-api-functions.php b/includes/wc-api-functions.php index 465dd8d3036..afa177750a2 100644 --- a/includes/wc-api-functions.php +++ b/includes/wc-api-functions.php @@ -122,7 +122,11 @@ function wc_rest_api_set_uploaded_image_as_attachment( $upload, $id = 0 ) { $title = ''; $content = ''; - if ( $image_meta = @wp_read_image_metadata( $upload['file'] ) ) { + if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) { + include_once( ABSPATH . 'wp-admin/includes/image.php' ); + } + + if ( $image_meta = wp_read_image_metadata( $upload['file'] ) ) { if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { $title = $image_meta['title']; }