Ok here is an initial hook that will add title, caption, description and created date.
if ( isset($GLOBALS["WFU_GLOBALS"]["WFU_DEBUG"]) ) $GLOBALS["WFU_GLOBALS"]["WFU_DEBUG"][3] = "ON";
if (!function_exists('wfu_debug_wfu_process_media_insert_function_handler')) {
function wfu_debug_wfu_process_media_insert_function_handler($res, $file_path, $userdata_fields, $page_id) {
$wp_upload_dir = wp_upload_dir();
$filetype = wp_check_filetype( wfu_basename( $file_path ), null );
$title = ( isset($userdata_fields[0]) && trim($userdata_fields[0]["value"]) != "" ? trim($userdata_fields[0]["value"]) : preg_replace( '/\.[^.]+$/', '', wfu_basename( $file_path ) ) );
$caption = ( isset($userdata_fields[1]) ? $userdata_fields[1]["value"] : "" );
$description = ( isset($userdata_fields[2]) ? $userdata_fields[2]["value"] : "" );
$created = ( isset($userdata_fields[3]) ? $userdata_fields[3]["value"] : "" );
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . wfu_basename( $file_path ),
'post_mime_type' => $filetype['type'],
'post_title' => $title,
'post_content' => $description,
'post_excerpt' => $caption,
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $file_path, $page_id );
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $file_path );
$attach_data["WFU User Data"]["Created"] = $created;
$update_attach = wp_update_attachment_metadata( $attach_id, $attach_data );
$filedata = wfu_get_filedata($file_path, true);
if ( $filedata != null ) {
$filedata["media"] = array( "type" => "data", "attach_id" => $attach_id );
wfu_save_filedata_from_id($filedata["general"]["idlog"], $filedata);
}
$res["result"] = 'R';
$res["output"] = $attach_id;
return $res;
}
add_filter('wfu_debug-wfu_process_media_insert', 'wfu_debug_wfu_process_media_insert_function_handler', 10, 4);
$GLOBALS['wfu_debug-wfu_process_media_insert'] = "1";
}
You need to add it at the end of functions.php file of your theme.
It is left for me to add category and tag taxonomies. Let me know that we are ok so far.
Nickolas