How to delete an image from the "media" directory?

Step 1

Get the absolute image path: How to get an absolute media (image) path programmatically by a relative path

Step 2.

Delete the file using a standard PHP function or a Magento 2 API (e.g.: How to create or delete a file in the temporary directory).

1 Like