我正在创建一个解析器,用于解析XML文件并将图像上载到媒体库。一切正常。
但上传后,也会根据媒体设置生成不同的图像。例如:中等、缩略图等。
我想停止仅为这些图像(通过解析上传的图像)生成不同大小的重复图像。这可能吗?
require_once( ABSPATH . \'wp-admin/includes/image.php\' );
$filetype = wp_check_filetype( basename( $uploadfile ), null );
$attachment = array(
\'guid\' => basename( $uploadfile ),
\'post_mime_type\' => $filetype[\'type\'],
\'post_title\' => preg_replace( \'/\\.[^.]+$/\', \'\', basename( $uploadfile ) ),
\'post_content\' => \'\',
\'post_status\' => \'inherit\',
);
$attach_id = wp_insert_attachment( $attachment, $uploadfile );
$attach_data = wp_generate_attachment_metadata( $attach_id, $uploadfile );
wp_update_attachment_metadata( $attach_id, $attach_data );
return $attach_id;