我正在使用插件从使用我的 wordpress 网站上的表单上传的图像中提取 EXIF 图像数据。到目前为止,它已正确上传图像并将其插入媒体库,但我认为它不会生成任何元数据信息并对其进行更新。我知道这一点,因为它曾经与我正在使用的另一种方法一起使用,但是在我升级了一些插件之后,它都停止了工作,我似乎无法修复它......下面有什么问题可能不允许元数据信息从上传的图像生成?我在附件页面上收到此错误:
注意:未定义变量:第 25 行 /mnt/soco-app/forms/wp-content/themes/twentytwelve/image.php 中的元数据
//Add uploaded image to media library
add_action("gform_after_submission", "post_submission", 10, 2);
function post_submission($entry) {
if($_FILES['input_5']) {/**TURN WP_DEBUG OFF WHEN FIXED**/
$filename = $entry[5];
$wp_filetype = wp_check_filetype(basename($filename), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$parent_post_id = 9; //ID of Parent Page
$attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id );
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
//require_once(ABSPATH . 'wp-includes/post.php');
//update_post_meta( $parent_post_id, '_wp_attachment_metadata', $attach_data );
wp_update_attachment_metadata( $attach_id, $attach_data );
}
}