I am creating a parser that is parsing an XML file and uploading an image to media library. Everything works fine.
But after uploading, the different image as per Media Settings are also generated. For eg: Medium, Thumbnail etc.
I want to stop generating the duplicate image of different size only to those images ( images that are uploaded from parsing ). Is that possible?
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;