Fixed image upload

This commit is contained in:
Claudio Sanches 2016-03-07 14:39:42 -03:00
parent bf286dfe96
commit a6df9969f4
1 changed files with 5 additions and 1 deletions

View File

@ -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'];
}