I am using this to allow users to delete their own posts on the front end of my site: <a onclick="return confirm('Move this post to the trash? You can restore it later.');" href="<?php echo ...
logged in as admin and trying to code that deletes posts to delete an attachment. got, <?php if (current_user_can('edit_post', $attachment->ID)) echo "<a href='" . ...