When using remark to manipulate markdown documents, you can use unist-util-remove to remove nodes of a particular type. You can combine it with unist-util-visit to remove nodes based on their parent's context in the AST.
In this example, we remove all images contained within heading nodes.