diff --git a/wp-app.php b/wp-app.php index a8966acc3b..1cf22428fd 100644 --- a/wp-app.php +++ b/wp-app.php @@ -26,6 +26,9 @@ require_once(ABSPATH . WPINC . '/atomlib.php'); /** Feed Handling API */ require_once(ABSPATH . WPINC . '/feed.php'); +/** Admin Image API for metadata updating */ +require_once(ABSPATH . '/wp-admin/includes/image.php'); + $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); /** @@ -814,9 +817,12 @@ EOD; $this->auth_required(__('Sorry, you do not have the right to edit this post.')); } + $upload_dir = wp_upload_dir( ); $location = get_post_meta($entry['ID'], '_wp_attached_file', true); $filetype = wp_check_filetype($location); + $location = "{$upload_dir['basedir']}/{$location}"; + if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext'])) $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); @@ -843,6 +849,8 @@ EOD; $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); } + wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) ); + log_app('function',"put_file($postID)"); $this->ok(); }