+ $result = $editor->save( $dst_file );
+ if ( is_wp_error( $result ) )
+ return $result;
+
+ return $dst_file;
+}
+
+/**
+ * Generate post thumbnail attachment meta data.
+ *
+ * @since 2.1.0
+ *
+ * @global array $_wp_additional_image_sizes
+ *
+ * @param int $attachment_id Attachment Id to process.
+ * @param string $file Filepath of the Attached image.
+ * @return mixed Metadata for attachment.
+ */
+function wp_generate_attachment_metadata( $attachment_id, $file ) {
+ $attachment = get_post( $attachment_id );
+
+ $metadata = array();
+ $support = false;
+ if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
+ $imagesize = getimagesize( $file );
+ $metadata['width'] = $imagesize[0];
+ $metadata['height'] = $imagesize[1];
+
+ // Make the file path relative to the upload dir.
+ $metadata['file'] = _wp_relative_upload_path($file);
+
+ // Make thumbnails and other intermediate sizes.
+ global $_wp_additional_image_sizes;
+
+ $sizes = array();
+ foreach ( get_intermediate_image_sizes() as $s ) {
+ $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
+ if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
+ $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
+ else
+ $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
+ if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
+ $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
+ else
+ $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
+ if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
+ $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; // For theme-added sizes
+ else
+ $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options