对于使用此代码上载的图像,我只想上载全尺寸图像和缩略图(而对于通过网站上载的图像,我需要所有尺寸)。但是,我不知道如何使其仅上载全尺寸/缩略图,因为此代码当前仅上载所有尺寸的图像:
$attachment = array(
\'post_author\' => "test",
\'post_date\' => $date,
\'post_date_gmt\' => gmdate(\'Y-m-d H:i:s\', strtotime($date) ),
\'post_title\' => "just some title",
\'post_status\' => \'inherit\',
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\',
\'post_name\' => "just some picture",
\'post_modified\' => $date,
\'post_modified_gmt\' => gmdate(\'Y-m-d H:i:s\', strtotime($date) ),
\'post_type\' => \'attachment\',
\'guid\' => $upload[\'url\'],
\'post_mime_type\' => $wp_filetype[\'type\'],
\'post_excerpt\' => \'\',
\'post_content\' => \'\'
);
$upload = wp_upload_bits( "picture.jpg", null, file_get_contents("picture.jpg") );
if ( $upload[\'error\'] )
echo "Failed uploading: " . $upload[\'error\'];
我能想到的唯一方法就是
attachment_id
然后
unlink
除了全尺寸和缩略图以外,所有尺寸都有,但看起来很凌乱。这样做的方法是什么?