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

Hii,

How can we delete the image from admin directory and also remove image from cache\1\image .

What is “admin” directory?

Hii,
i mean to say i want to delete image from back-end path like image save in /pub/media/catalog/product/cache/1/image/… thumbnails which is admin product path.

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