This function deletes an attachment and all of its derivatives.
<?php wp_delete_attachment( $attachmentid, $force_delete ); ?>
Returns false on failure, post data on success. This should be checked using the identity operator ( === ) instead of the normal equality operator because of the possibility of a returned 0 or empty array:
<?php if ( false === wp_delete_attachment( $attachmentid ) ) do something; ?>
This function fires the delete_attachment action hook, passing the attachment's ID ($postid).
To delete an attachment with an ID of '76':
<?php wp_delete_attachment( 76 ); ?>
wp_delete_attachment() is located in