Site icon Hip-Hop Website Design and Development

How to delete all instances of the image using REST API

When I post an image to WordPress, it is reproduced automatically to multiple images of different sizes.

For example, when I upload image1.png, it is uploaded as multiple images as such:

image1.png         (Original)

image1-167x93.png  (Resized)

image1-340x180.png (Resized)

image1-600x300.png (Resized)

etc..

I am trying to delete image1.png through REST API, however, all the resized images remain in the server. Is there a way to delete image1.png and all its child images.

To delete image1.png, I issue a DELETE request using REST API as such:

https://www.mywebsite.com/wp-json/wp/v2/media/<imageid>?force=True

Please help how to accomplish the above programmatically, preferably via REST API.